0

I'm trying to make a php files, to apply coupon code to shipping cart. I explain. We have a mobile-commerce application, and wanna add coupon code. Creating them on magento, adding rules, date, products, there is no problem here, but when customer have choose products, they enter the coupon code in a text field. My php files take the code they enter, and the shopping card Id (if there is one ? ) with a GET method, check if the coupon can be apply (rules, date, products, obviously ask magento "Can he does it ?"), and if magento says "yes", return the final price, or reduction (return like '5%' or '543$'), or return "error" if the coupon is not validate.

I try to look some code here : http://inchoo.net/ecommerce/magento/programming-magento/programmatically-create-apply-and-delete-shopping-cart-price-rule-in-magento/ also look at the magento's documentation, but not abble to finally find what I wanna do.

I don't really know where to start, every helps are welcome =)

EDIT: I'm actually here :

$couponCode = $_GET['couponCode'];
$shoppingCartId = $_GET['shoppingCartId'];

$result = $proxy->call($session, "cart_coupon.add", array($shoppingCartId, $couponCode));

but I don't know what to do with my result, (what can I return).

closed as too broad by Marius, Vladimir Kerkhoff, Sander Mangel, brentwpeterson, Amit Bera Nov 11 '14 at 12:15

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

2

What this will do is simply add the coupon to the cart. You will then need to make a further call to the api to get the cart totals.

It is all documented at http://www.magentocommerce.com/api/soap/checkout/cart/cart.totals.html and a call like the following:

$client = new SoapClient('http://magentohost/api/soap/?wsdl');

// If somestuff requires api authentification,
// then get a session token
$session = $client->login('apiUser', 'apiKey');

$result = $client->call($session, 'cart.totals', '15');
var_dump ($result);

Should give you an array of all the totals which will include the discounts.

  • Not what I asked for, but totally works, I just don't look the good place to find what I want. Thank's ;) – Malerick Nov 12 '14 at 13:43

Not the answer you're looking for? Browse other questions tagged or ask your own question.