When a customer of a Gambio shop redeems a voucher by entering the voucher code in the shopping cart, the voucher is processed, but it is not deducted from the total displayed in the shopping cart. From a user experience and conversion rate perspective, it is better to display the applied discount directly. Here is a suggested solution for Gambio GX2:
1) Why do everything ourselves? To prepare for our implementation, we use the Gambio plugin "Voucher Display in Shopping Cart" from Alkim Media (by the way, very nice people to deal with) and upload the directories
\user_classes\overloads
and
\user_classes\overloads
to our main directory, as well as the files
\lang\german\gutschein_anzeige.conf
and
\templates\EyeCandy\boxes
For the latter, of course, select the appropriate template directory or manually modify the existing file according to the plugin file if other modifications are already present (as is the case in our installation). The same applies to the file
\templates\EyeCandy\module\order_details-USERMOD.html
Now copy the file
\templates\EyeCandy\usermod
to the appropriate template directory, and we are already well on our way.
2) We now also need to make sure that PayPal Express Checkout works from the shopping cart (if enabled; if not, proceed to point 3). With the current changes, if only the grand total is updated, PayPal's validation will reject the request because the item total does not match the grand total. In other words, the sum of the individual items is higher than the reduced grand total by exactly the discount amount. We know the solution to this problem from other shop systems as well (including Magento OneStepCheckout): Before sending the shopping cart to PayPal, we add an additional item with a negative price equal to the discount amount, which balances out the difference between the item total and the grand total. To do this, we modify the file
\gm\classes\GMPayPal.php
or the corresponding override:
First, we pass the reduced grand total to PayPal. After (around line 310)
// items unset($_SESSION['shipping']);
we replace the existing code with
if (isset($_SESSION['customer_id']) && $_SESSION['cc_id']) { global $order; $order = new order(); require_once (DIR_WS_CLASSES . 'order_total.php'); $order_total_modules = new order_total(); $order_total_modules->collect_posts(); $order_total_modules->pre_confirmation_check(); $order_total_modules->process(); } else { $order = new order(); }
We then add the pseudo-item (after inserting the section shown above, around line 475). Thus, after
else if($remainingTotal < 0) { // discount $itemAmount = new BasicAmountType($currencyCode, self::_formatAmount($remainingTotal)); $itemDetails = new PaymentDetailsItemType(); $itemDetails->Name = $this->transcodeOutbound($this->get_text('discount')); $itemDetails->Amount = $itemAmount; $itemDetails->Quantity = 1; $t_paymentdetailsitem[] = $itemDetails; $itemTotal += $remainingTotal; }
we replace the existing lines with
if(array_key_exists('deduction', $p_order->info)) { // deduction $deduction = -$p_order->info['deduction']; $itemAmount = new BasicAmountType($currencyCode, self::_formatAmount($deduction)); $itemDetails = new PaymentDetailsItemType(); $itemDetails->Name = $this->transcodeOutbound($this->get_text('discount')); $itemDetails->Amount = $itemAmount; $itemDetails->Quantity = 1; $t_paymentdetailsitem[] = $itemDetails; $itemTotal += $deduction; }
This adds the item, and PayPal's validation now works without any problems.
3) Done.
