0

I am currently developing a e-commerce site using xcart 4.7 platinum. I enabled discount coupon module. In current implementation, a particular coupon is only applicable for a single product or a single category and its subcategories. How can it changed to accept multiple products and category like in open cart? Or add multiple coupons at a time in cart?

1 Answers1

0

1) Create a new table like

xcart_discount_coupons_products (
  id mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  productid int(11) NOT NULL DEFAULT '0',
  ... keys
)

2) Add a new field to the xcart_discount_coupons table

ALTER TABLE xcart_discount_coupons add pid_link mediumint(8) unsigned NOT NULL DEFAULT 0 COMMENT 'Link to xcart_discount_coupons_products.id';
Add a mysql key for xcart_discount_coupons.pid_link if needed

3)Adjust the func_is_valid_coupon function
from the modules/Discount_Coupons/func.php file
to accept new multiple products condition.

} elseif ($my_coupon['pid_link'] > 0) {
......
           Your new code will slightly different from the "if ($my_coupon['productid'] > 0)" handler
......

4) Adjust the function func_calculate_discounts from
include/func/func.cart.php
You should add a new condition for your new $discount_coupon_data['pid_link'] field here

            if ($discount_coupon_data['productid'] > 0) {
......
                if ($product['productid'] != $discount_coupon_data['productid'])
                    continue;

5)Change the back-end files to accept multiple products
You should change the files skin/common_files/modules/Discount_Coupons/coupons.tpl
provider/coupons.php

By the way, you can type multiple SKUs separated by comma
SKU17482,SKU17511, from X-Cart version 4.7.4
https://www.x-cart.com/blog/4-7-4-released.html#search-faster

Your should adjust this part of code to accept multiple SKUs
provider/coupons.php

$newproduct_ids = !empty($productid_new) ? array(intval($productid_new)) : XCAjaxSearchProducts::extractIdsFromStr($productname);
$productid_new = $newproduct_ids[0];

6)Repeat the steps for categories

Ildar Amankulov
  • 526
  • 4
  • 19