hideaki Posted September 1, 2014 Share Posted September 1, 2014 Hi guys, I've got this custom module that creates "Gift Cards" as Cart Rules. Basically this "Gift Card" has a value (e.g. $100) that the customers can use to reduce any amount from it (e.g. $20, which will leave $80 left in that particular gift card). However, I am having a bug now that will increase the value of the amount to use to the full amount of Total Products. For example, 1. Customer adds $16.50 worth of products to cart 2. Customer uses $10 from gift card with $100 ($90 should be left) 3. Customer increases quantity of product to 2 (total products price = $33) 4. Amount to use from gift card automatically becomes $33 (instead of $10) I've been working a whole day to resolve the problem, but can't seem to be going anywhere. So I've decided that I'll just remove the "Gift Card" cart rule instead. I've written something like this, but I have no idea where to fit it in. // SQL: SELECT DISTINCT `ccr`.`id_cart`, `ccr`.`id_cart_rule` FROM `ps_cart_cart_rule` AS `ccr` LEFT JOIN `ps_cart_rule_lang` AS `crl` ON `ccr`.`id_cart_rule` = `crl`.`id_cart_rule` WHERE `crl`.`name` LIKE '%gift card%' AND `ccr`.`id_cart` = 1 // CUSTOM: Remove Gift Card rules // Get the IDs of cart rules in cart $cartRulesInCart = Db::getInstance()->executeS('SELECT DISTINCT `ccr`.`id_cart_rule` FROM `'._DB_PREFIX_.'cart_cart_rule` AS `ccr` LEFT JOIN `'._DB_PREFIX_.'cart_rule_lang` AS `crl` ON `ccr`.`id_cart_rule` = `crl`.`id_cart_rule` WHERE `crl`.`name` LIKE \'%gift card%\' AND `ccr`.`id_cart` = '.(int)$this->id.''); // Remove cart rules with removeCartRule() foreach ($cartRulesInCart as $cartRuleIdToRemove) { $this->removeCartRule($cartRuleIdToRemove); } It should be in called when a product is added to cart, or quantity is changed on the Shopping Cart Summary. Any idea/s where I should place this? I have tried updateQty(), add() and update() functions in Cart.php but to no avail. Thanks for any help! Link to comment Share on other sites More sharing options...
hideaki Posted September 3, 2014 Author Share Posted September 3, 2014 Anyone with any idea/s? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now