Forum

Thread tagged as: Problem, Error, Shop

Discount code applied multiple times - cache issue?

Hi there,

I've came across a strange behavior within the Perch Shop. It resulted in someone ] accidentally applied their discount code twice and couldn’t remove it so he ended up with double discount.

Apparently the problem occurs, if you add something to cart, apply code, clear cart, go away, come back add the same product again, the discount code automatically appears, it hasn’t been cleared when the cart was cleared.

Is there anything we can do about it?

Best regards, Damian

Damian Drozdowicz

Damian Drozdowicz 0 points

  • 4 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Is it something you're able to reproduce?

Damian Drozdowicz

Damian Drozdowicz 0 points
Registered Developer

Yes.

I wonder if there is a way to clear the code for good when cart is re-set?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Can you show me the debug output from the point the promotion is applied twice?

Damian Drozdowicz

Damian Drozdowicz 0 points
Registered Developer

It's more that the promotion persists even if there are no items in the cart.

So when you: 1. Add a product 2. Set a discount code 3. Remove the product 4. Add a product - discount code is still applied

Ideally we'd like to remove the discount code when cart is emptied. Is there a quick way to do so?

Rachel Andrew

Rachel Andrew 394 points
Perch Support

Can we see the debug output please?

Damian Drozdowicz

Damian Drozdowicz 0 points
Registered Developer

<table class="perch-debug"> <tbody><tr>     <th>Debug Message</th> </tr><tr><td class="db" title="PerchContent_Pages.class.php: PerchContent_Pages->find_by_path(): "> <span class="debug-badge"><span class="debug-brkt">[</span>1<span class="debug-brkt">]</span></span> SELECT * FROM perch2_pages WHERE pagePath='/cart/index.php' LIMIT 1</td></tr><tr><td class="db" title="PerchShop_Cart.class.php: PerchShop_Cart->get_cart_field(): "> <span class="debug-badge"><span class="debug-brkt">[</span>1<span class="debug-brkt">]</span></span> SELECT * FROM perch2_shop_cart WHERE cartID=17208</td></tr><tr><td class="db" title="PerchShop_Cart.class.php: PerchShop_Cart->get_cart_field(): "> <span class="debug-badge"><span class="debug-brkt">[</span>1<span class="debug-brkt">]</span></span> SELECT * FROM perch2_shop_cart WHERE cartID=17208</td></tr><tr><td class="marker" title="PerchShop_Cart.class.php: PerchShop_Cart->calculate_cart(): ">------------------------------ Calculating cart ------------------------------</td></tr><tr><td class="db" title="PerchShop_Cart.class.php: PerchShop_Cart->get_cart_field(): "> <span class="debug-badge"><span class="debug-brkt">[</span>1<span class="debug-brkt">]</span></span> SELECT * FROM perch2_shop_cart WHERE cartID=17208</td></tr><tr><td class="db" title="PerchShop_Cart.class.php: PerchShop_Cart->calculate_cart(): "> <span class="debug-badge"><span class="debug-brkt">[</span>1<span class="debug-brkt">]</span></span> SELECT * FROM perch2_shop_cart WHERE cartID=17208</td></tr><tr><td class="db" title="PerchFactory.class.php: PerchFactory->find(): "> <span class="debug-badge"><span class="debug-brkt">[</span>1<span class="debug-brkt">]</span></span> SELECT * FROM perch2_shop_tax_locations WHERE locationID=1 AND locationDeleted IS NULL  LIMIT 1</td></tr><tr><td class="db" title="PerchDB_MySQL.class.php: PerchDB_MySQL->get_value(): "> <span class="debug-badge"><span class="debug-brkt">[</span>1<span class="debug-brkt">]</span></span> SELECT locationID FROM perch2_shop_tax_locations WHERE locationIsHome=1 LIMIT 1</td></tr><tr><td class="db" title="PerchFactory.class.php: PerchFactory->find(): "> <span class="debug-badge"><span class="debug-brkt">[</span>1<span class="debug-brkt">]</span></span> SELECT * FROM perch2_shop_tax_locations WHERE locationID=1 AND locationDeleted IS NULL  LIMIT 1</td></tr><tr><td class="db" title="PerchFactory.class.php: PerchFactory->find(): "> <span class="debug-badge"><span class="debug-brkt">[</span>1<span class="debug-brkt">]</span></span> SELECT * FROM perch2_shop_currencies WHERE currencyID=47 LIMIT 1</td></tr><tr><td class="db" title="PerchShop_Cart.class.php: PerchShop_Cart->calculate_cart(): "> <span class="debug-badge"><span class="debug-brkt">[</span>1<span class="debug-brkt">]</span></span> SELECT COUNT(productID) AS product_count, SUM(itemQty) AS item_count FROM perch2_shop_cart_items WHERE cartID=17208</td></tr><tr><td class="db" title="PerchSettings.class.php: PerchSettings->get(): "> <span class="debug-badge"><span class="debug-brkt">[</span>39<span class="debug-brkt">]</span></span> SELECT DISTINCT settingID, settingValue FROM perch2_settings WHERE userID=0</td></tr><tr><td class="log" title="PerchShop_Cart.class.php: PerchShop_Cart->get_cart(): ">Tax mode: exc</td></tr><tr><td class="db" title="PerchFactory.class.php: PerchFactory->get_by(): "> <span class="debug-badge"><span class="debug-brkt">[</span>1<span class="debug-brkt">]</span></span> SELECT  * FROM perch2_shop_cart_items WHERE cartID=17208  ORDER BY itemID ASC</td></tr><tr><td class="db" title="PerchFactory.class.php: PerchFactory->find(): "> <span class="debug-badge"><span class="debug-brkt">[</span>1<span class="debug-brkt">]</span></span> SELECT * FROM perch2_shop_products WHERE productID=22 AND productDeleted IS NULL  LIMIT 1</td></tr><tr><td class="db" title="PerchFactory.class.php: PerchFactory->find(): "> <span class="debug-badge"><span class="debug-brkt">[</span>1<span class="debug-brkt">]</span></span> SELECT * FROM perch2_shop_products WHERE productID=20 AND productDeleted IS NULL  LIMIT 1</td></tr><tr><td class="db" title="PerchShop_Product.class.php: PerchShop_Product->get_variant_select_opts(): "> <span class="debug-badge"><span class="debug-brkt">[</span>2<span class="debug-brkt">]</span></span> SELECT productID, productVariantDesc, stock_level FROM perch2_shop_products
                WHERE parentID=20 AND productDeleted IS NULL
                ORDER BY productOrder ASC</td></tr><tr><td class="db" title="PerchShop_Options.class.php: PerchShop_Options->get_for_product(): "> <span class="debug-badge"><span class="debug-brkt">[</span>1<span class="debug-brkt">]</span></span> SELECT o.* FROM perch2_shop_options o, perch2_shop_product_options po 
                WHERE o.optionID=po.optionID AND po.productID=20
                    AND o.optionDeleted IS NULL
                ORDER BY optionPrecendence ASC</td></tr><tr><td class="db" title="PerchShop_OptionValues.class.php: PerchShop_OptionValues->get_edit_values(): "> <span class="debug-badge"><span class="debug-brkt">[</span>2<span class="debug-brkt">]</span></span> SELECT valueID AS id, valueTitle AS title, valueSKUCode AS skucode
                FROM perch2_shop_option_values WHERE optionID=2 AND valueDeleted IS NULL 
                ORDER BY valueOrder ASC</td></tr><tr><td class="db" title="PerchShop_OptionValues.class.php: PerchShop_OptionValues->get_for_product(): "> <span class="debug-badge"><span class="debug-brkt">[</span>2<span class="debug-brkt">]</span></span> SELECT pov.prodoptID, pov.optionID, pov.valueID, o.optionTitle, ov.*
                    FROM perch2_shop_product_option_values pov, perch2_shop_options o, perch2_shop_option_values ov
                    WHERE pov.productID='20' AND pov.optionID=o.optionID AND pov.valueID=ov.valueID AND o.optionDeleted IS NULL AND ov.valueDeleted IS NULL
                        AND o.optionID='2'
                    ORDER BY o.optionPrecendence ASC, ov.valueOrder ASC</td></tr><tr><td class="db" title="PerchFactory.class.php: PerchFactory->find(): "> <span class="debug-badge"><span class="debug-brkt">[</span>1<span class="debug-brkt">]</span></span> SELECT * FROM perch2_shop_products WHERE productID=20 AND productDeleted IS NULL  LIMIT 1</td></tr><tr><td class="db" title="PerchFactory.class.php: PerchFactory->find(): "> <span class="debug-badge"><span class="debug-brkt">[</span>1<span class="debug-brkt">]</span></span> SELECT * FROM perch2_shop_tax_groups WHERE groupID=1 AND groupDeleted IS NULL  LIMIT 1</td></tr><tr><td class="db" title="PerchDB_MySQL.class.php: PerchDB_MySQL->get_value(): "> <span class="debug-badge"><span class="debug-brkt">[</span>1<span class="debug-brkt">]</span></span> SELECT r.rateValue FROM perch2_shop_tax_group_rates gr, perch2_shop_tax_rates r 
                WHERE gr.rateID=r.rateID AND gr.groupID=1 AND gr.locationID=1</td></tr><tr><td class="db" title="PerchFactory.class.php: PerchFactory->find(): "> <span class="debug-badge"><span class="debug-brkt">[</span>1<span class="debug-brkt">]</span></span> SELECT * FROM perch2_shop_products WHERE productID=20 AND productDeleted IS NULL  LIMIT 1</td></tr><tr><td class="db" title="PerchFactory.class.php: PerchFactory->find(): "> <span class="debug-badge"><span class="debug-brkt">[</span>1<span class="debug-brkt">]</span></span> SELECT * FROM perch2_shop_products WHERE productID=20 AND productDeleted IS NULL  LIMIT 1</td></tr><tr><td class="db" title="PerchShop_Product.class.php: PerchShop_Product->get_variant_select_opts(): "> <span class="debug-badge"><span class="debug-brkt">[</span>2<span class="debug-brkt">]</span></span> SELECT productID, productVariantDesc, stock_level FROM perch2_shop_products
                WHERE parentID=20 AND productDeleted IS NULL
                ORDER BY productOrder ASC</td></tr><tr><td class="db" title="PerchShop_Options.class.php: PerchShop_Options->get_for_product(): "> <span class="debug-badge"><span class="debug-brkt">[</span>1<span class="debug-brkt">]</span></span> SELECT o.* FROM perch2_shop_options o, perch2_shop_product_options po 
                WHERE o.optionID=po.optionID AND po.productID=20
                    AND o.optionDeleted IS NULL
                ORDER BY optionPrecendence ASC</td></tr><tr><td class="db" title="PerchShop_OptionValues.class.php: PerchShop_OptionValues->get_edit_values(): "> <span class="debug-badge"><span class="debug-brkt">[</span>2<span class="debug-brkt">]</span></span> SELECT valueID AS id, valueTitle AS title, valueSKUCode AS skucode
                FROM perch2_shop_option_values WHERE optionID=2 AND valueDeleted IS NULL 
                ORDER BY valueOrder ASC</td></tr><tr><td class="db" title="PerchShop_OptionValues.class.php: PerchShop_OptionValues->get_for_product(): "> <span class="debug-badge"><span class="debug-brkt">[</span>2<span class="debug-brkt">]</span></span> SELECT pov.prodoptID, pov.optionID, pov.valueID, o.optionTitle, ov.*
                    FROM perch2_shop_product_option_values pov, perch2_shop_options o, perch2_shop_option_values ov
                    WHERE pov.productID='20' AND pov.optionID=o.optionID AND pov.valueID=ov.valueID AND o.optionDeleted IS NULL AND ov.valueDeleted IS NULL
                        AND o.optionID='2'
                    ORDER BY o.optionPrecendence ASC, ov.valueOrder ASC</td></tr><tr><td class="db" title="PerchShop_Promotions.class.php: PerchShop_Promotions->get_currently_active(): "> <span class="debug-badge"><span class="debug-brkt">[</span>6<span class="debug-brkt">]</span></span> SELECT * FROM perch2_shop_promotions
                WHERE promoFrom&lt;='2017-01-19 12:33:00' AND promoTo&gt;'2017-01-19 12:33:00' AND promoActive=1 AND promoDeleted IS NULL
                ORDER BY promoOrder ASC</td></tr><tr><td class="log" title="PerchShop_Cart.class.php: PerchShop_Cart->calculate_cart(): ">Promo (Discount) skipped: discount code not applied.</td></tr><tr><td class="log" title="PerchShop_Cart.class.php: PerchShop_Cart->calculate_cart(): ">Promo (10% Discount on Product Test) skipped: discount code not applied.</td></tr><tr><td class="log" title="PerchShop_Cart.class.php: PerchShop_Cart->calculate_cart(): ">Promo (Christmas sale) skipped: discount code not applied.</td></tr><tr><td class="log" title="PerchShop_Cart.class.php: PerchShop_Cart->calculate_cart(): ">Promo (Sale) skipped: discount code not applied.</td></tr><tr><td class="db" title="PerchDB_MySQL.class.php: PerchDB_MySQL->get_value(): "> <span class="debug-badge"><span class="debug-brkt">[</span>0<span class="debug-brkt">]</span></span> SELECT COUNT(*) FROM perch2_shop_order_promotions
                WHERE promoID=6</td></tr><tr><td class="log" title="PerchShop_Cart.class.php: PerchShop_Cart->calculate_cart(): ">Promo (Minus £150) qualifies!</td></tr><tr><td class="log" title="PerchShop_Cart.class.php: PerchShop_Cart->calculate_cart(): ">Fixed amount discount promo</td></tr><tr><td class="log" title="PerchShop_Cart.class.php: PerchShop_Cart->calculate_cart(): ">Promo (test) skipped: discount code not applied.</td></tr><tr><td class="db" title="PerchFactory.class.php: PerchFactory->find(): "> <span class="debug-badge"><span class="debug-brkt">[</span>1<span class="debug-brkt">]</span></span> SELECT * FROM perch2_shop_products WHERE productID=20 AND productDeleted IS NULL  LIMIT 1</td></tr><tr><td class="db" title="PerchShop_Product.class.php: PerchShop_Product->get_variant_select_opts(): "> <span class="debug-badge"><span class="debug-brkt">[</span>2<span class="debug-brkt">]</span></span> SELECT productID, productVariantDesc, stock_level FROM perch2_shop_products
                WHERE parentID=20 AND productDeleted IS NULL
                ORDER BY productOrder ASC</td></tr><tr><td class="db" title="PerchShop_Options.class.php: PerchShop_Options->get_for_product(): "> <span class="debug-badge"><span class="debug-brkt">[</span>1<span class="debug-brkt">]</span></span> SELECT o.* FROM perch2_shop_options o, perch2_shop_product_options po 
                WHERE o.optionID=po.optionID AND po.productID=20
                    AND o.optionDeleted IS NULL
                ORDER BY optionPrecendence ASC</td></tr><tr><td class="db" title="PerchShop_OptionValues.class.php: PerchShop_OptionValues->get_edit_values(): "> <span class="debug-badge"><span class="debug-brkt">[</span>2<span class="debug-brkt">]</span></span> SELECT valueID AS id, valueTitle AS title, valueSKUCode AS skucode
                FROM perch2_shop_option_values WHERE optionID=2 AND valueDeleted IS NULL 
                ORDER BY valueOrder ASC</td></tr><tr><td class="db" title="PerchShop_OptionValues.class.php: PerchShop_OptionValues->get_for_product(): "> <span class="debug-badge"><span class="debug-brkt">[</span>2<span class="debug-brkt">]</span></span> SELECT pov.prodoptID, pov.optionID, pov.valueID, o.optionTitle, ov.*
                    FROM perch2_shop_product_option_values pov, perch2_shop_options o, perch2_shop_option_values ov
                    WHERE pov.productID='20' AND pov.optionID=o.optionID AND pov.valueID=ov.valueID AND o.optionDeleted IS NULL AND ov.valueDeleted IS NULL
                        AND o.optionID='2'
                    ORDER BY o.optionPrecendence ASC, ov.valueOrder ASC</td></tr><tr><td class="db" title="PerchFactory.class.php: PerchFactory->find(): "> <span class="debug-badge"><span class="debug-brkt">[</span>1<span class="debug-brkt">]</span></span> SELECT * FROM perch2_shop_products WHERE productID=20 AND productDeleted IS NULL  LIMIT 1</td></tr><tr><td class="db" title="PerchShop_Product.class.php: PerchShop_Product->get_variant_select_opts(): "> <span class="debug-badge"><span class="debug-brkt">[</span>2<span class="debug-brkt">]</span></span> SELECT productID, productVariantDesc, stock_level FROM perch2_shop_products
                WHERE parentID=20 AND productDeleted IS NULL
                ORDER BY productOrder ASC</td></tr><tr><td class="db" title="PerchShop_Options.class.php: PerchShop_Options->get_for_product(): "> <span class="debug-badge"><span class="debug-brkt">[</span>1<span class="debug-brkt">]</span></span> SELECT o.* FROM perch2_shop_options o, perch2_shop_product_options po 
                WHERE o.optionID=po.optionID AND po.productID=20
                    AND o.optionDeleted IS NULL
                ORDER BY optionPrecendence ASC</td></tr><tr><td class="db" title="PerchShop_OptionValues.class.php: PerchShop_OptionValues->get_edit_values(): "> <span class="debug-badge"><span class="debug-brkt">[</span>2<span class="debug-brkt">]</span></span> SELECT valueID AS id, valueTitle AS title, valueSKUCode AS skucode
                FROM perch2_shop_option_values WHERE optionID=2 AND valueDeleted IS NULL 
                ORDER BY valueOrder ASC</td></tr><tr><td class="db" title="PerchShop_OptionValues.class.php: PerchShop_OptionValues->get_for_product(): "> <span class="debug-badge"><span class="debug-brkt">[</span>2<span class="debug-brkt">]</span></span> SELECT pov.prodoptID, pov.optionID, pov.valueID, o.optionTitle, ov.*
                    FROM perch2_shop_product_option_values pov, perch2_shop_options o, perch2_shop_option_values ov
                    WHERE pov.productID='20' AND pov.optionID=o.optionID AND pov.valueID=ov.valueID AND o.optionDeleted IS NULL AND ov.valueDeleted IS NULL
                        AND o.optionID='2'
                    ORDER BY o.optionPrecendence ASC, ov.valueOrder ASC</td></tr><tr><td class="db" title="PerchFactory.class.php: PerchFactory->find(): "> <span class="debug-badge"><span class="debug-brkt">[</span>1<span class="debug-brkt">]</span></span> SELECT * FROM perch2_shop_products WHERE productID=20 AND productDeleted IS NULL  LIMIT 1</td></tr><tr><td class="db" title="PerchShop_Product.class.php: PerchShop_Product->get_variant_select_opts(): "> <span class="debug-badge"><span class="debug-brkt">[</span>2<span class="debug-brkt">]</span></span> SELECT productID, productVariantDesc, stock_level FROM perch2_shop_products
                WHERE parentID=20 AND productDeleted IS NULL
                ORDER BY productOrder ASC</td></tr><tr><td class="db" title="PerchShop_Options.class.php: PerchShop_Options->get_for_product(): "> <span class="debug-badge"><span class="debug-brkt">[</span>1<span class="debug-brkt">]</span></span> SELECT o.* FROM perch2_shop_options o, perch2_shop_product_options po 
                WHERE o.optionID=po.optionID AND po.productID=20
                    AND o.optionDeleted IS NULL
                ORDER BY optionPrecendence ASC</td></tr><tr><td class="db" title="PerchShop_OptionValues.class.php: PerchShop_OptionValues->get_edit_values(): "> <span class="debug-badge"><span class="debug-brkt">[</span>2<span class="debug-brkt">]</span></span> SELECT valueID AS id, valueTitle AS title, valueSKUCode AS skucode
                FROM perch2_shop_option_values WHERE optionID=2 AND valueDeleted IS NULL 
                ORDER BY valueOrder ASC</td></tr><tr><td class="db" title="PerchShop_OptionValues.class.php: PerchShop_OptionValues->get_for_product(): "> <span class="debug-badge"><span class="debug-brkt">[</span>2<span class="debug-brkt">]</span></span> SELECT pov.prodoptID, pov.optionID, pov.valueID, o.optionTitle, ov.*
                    FROM perch2_shop_product_option_values pov, perch2_shop_options o, perch2_shop_option_values ov
                    WHERE pov.productID='20' AND pov.optionID=o.optionID AND pov.valueID=ov.valueID AND o.optionDeleted IS NULL AND ov.valueDeleted IS NULL
                        AND o.optionID='2'
                    ORDER BY o.optionPrecendence ASC, ov.valueOrder ASC</td></tr><tr><td class="log" title="PerchShop_Runtime.class.php: PerchShop_Runtime->get_cart(): ">Using cart from cache.</td></tr><tr><td class="db" title="PerchFactory.class.php: PerchFactory->find(): "> <span class="debug-badge"><span class="debug-brkt">[</span>1<span class="debug-brkt">]</span></span> SELECT * FROM perch2_shop_products WHERE productID=20 AND productDeleted IS NULL  LIMIT 1</td></tr><tr><td class="db" title="PerchShop_Product.class.php: PerchShop_Product->get_variant_select_opts(): "> <span class="debug-badge"><span class="debug-brkt">[</span>2<span class="debug-brkt">]</span></span> SELECT productID, productVariantDesc, stock_level FROM perch2_shop_products
                WHERE parentID=20 AND productDeleted IS NULL
                ORDER BY productOrder ASC</td></tr><tr><td class="db" title="PerchShop_Options.class.php: PerchShop_Options->get_for_product(): "> <span class="debug-badge"><span class="debug-brkt">[</span>1<span class="debug-brkt">]</span></span> SELECT o.* FROM perch2_shop_options o, perch2_shop_product_options po 
                WHERE o.optionID=po.optionID AND po.productID=20
                    AND o.optionDeleted IS NULL
                ORDER BY optionPrecendence ASC</td></tr><tr><td class="db" title="PerchShop_OptionValues.class.php: PerchShop_OptionValues->get_edit_values(): "> <span class="debug-badge"><span class="debug-brkt">[</span>2<span class="debug-brkt">]</span></span> SELECT valueID AS id, valueTitle AS title, valueSKUCode AS skucode
                FROM perch2_shop_option_values WHERE optionID=2 AND valueDeleted IS NULL 
                ORDER BY valueOrder ASC</td></tr><tr><td class="db" title="PerchShop_OptionValues.class.php: PerchShop_OptionValues->get_for_product(): "> <span class="debug-badge"><span class="debug-brkt">[</span>2<span class="debug-brkt">]</span></span> SELECT pov.prodoptID, pov.optionID, pov.valueID, o.optionTitle, ov.*
                    FROM perch2_shop_product_option_values pov, perch2_shop_options o, perch2_shop_option_values ov
                    WHERE pov.productID='20' AND pov.optionID=o.optionID AND pov.valueID=ov.valueID AND o.optionDeleted IS NULL AND ov.valueDeleted IS NULL
                        AND o.optionID='2'
                    ORDER BY o.optionPrecendence ASC, ov.valueOrder ASC</td></tr><tr><td class="template" title="PerchAPI_Template.class.php: PerchAPI_Template->set(): "> <span class="debug-badge"><span class="debug-brkt">[</span>1<span class="debug-brkt">]</span></span> Using template: /templates/shop/cart/cart.html</td></tr><tr><td class="template" title="PerchContent_Page.class.php: PerchContent_Page->template_attributes(): ">Using template: /templates/pages/attributes/seo.html</td></tr><tr><td class="template" title="PerchContent_Page.class.php: PerchContent_Page->template_attributes(): ">Using template: /templates/pages/attributes/facebook.html</td></tr><tr><td class="template" title="PerchContent_Page.class.php: PerchContent_Page->template_attributes(): ">Using template: /templates/pages/attributes/twitter.html</td></tr><tr><td class="db" title="PerchContent_Runway.class.php: PerchContent_Runway->get_collection(): "> <span class="debug-badge"><span class="debug-brkt">[</span>1<span class="debug-brkt">]</span></span> SELECT collectionID, collectionTemplate  FROM perch2_collections WHERE collectionKey='Profiles'</td></tr><tr><td class="db" title="PerchContent_Runway.class.php: PerchContent_Runway->get_collection(): "> <span class="debug-badge"><span class="debug-brkt">[</span>10<span class="debug-brkt">]</span></span> SELECT * FROM ( SELECT  idx.itemID, ci.collectionID, ci.itemJSON,  idx2.indexValue as sortval  FROM perch2_collection_index idx 
                            JOIN perch2_collection_items ci ON idx.itemID=ci.itemID AND idx.itemRev=ci.itemRev AND idx.collectionID=ci.collectionID
                            JOIN perch2_collection_revisions cr ON idx.itemID=cr.itemID AND idx.itemRev=cr.itemRev AND idx.collectionID=ci.collectionID
                            JOIN perch2_collection_index idx2 ON idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev   AND idx2.indexKey='_order'  WHERE (idx.collectionID=2) AND ((idx.indexKey='live' AND idx.indexValue=1))  AND idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev
                    ) as tbl GROUP BY itemID, itemJSON, sortval  ORDER BY sortval ASC </td></tr><tr><td class="template" title="PerchContent_Runway.class.php: PerchContent_Runway->get_collection(): "> <span class="debug-badge"><span class="debug-brkt">[</span>10<span class="debug-brkt">]</span></span> Using template: /templates/content/partials/widget_how_can_i_help_you.html</td></tr><tr><td class="template" title="PerchAPI_Template.class.php: PerchAPI_Template->set(): ">Using template: /templates/forms/callback-request.html</td></tr><tr><td class="db" title="PerchContent_Pages.class.php: PerchContent_Pages->get_navigation(): "> <span class="debug-badge"><span class="debug-brkt">[</span>1<span class="debug-brkt">]</span></span> SELECT pageID, pageParentID, pageDepth, pageTreePosition FROM perch2_pages WHERE pagePath='/product-test' OR pageSortPath='/product-test' LIMIT 1</td></tr><tr><td class="db" title="PerchContent_Pages.class.php: PerchContent_Pages->get_navigation(): "> <span class="debug-badge"><span class="debug-brkt">[</span>6<span class="debug-brkt">]</span></span> SELECT * FROM perch2_pages WHERE pageNew=0  AND pageHidden=0  AND pageTreePosition LIKE '000-004%'  AND pageDepth &gt;=1 AND pageDepth&lt;=2  ORDER BY pageTreePosition ASC</td></tr><tr><td class="db" title="PerchDB_MySQL.class.php: PerchDB_MySQL->get_value(): "> <span class="debug-badge"><span class="debug-brkt">[</span>1<span class="debug-brkt">]</span></span> SELECT pageTreePosition FROM perch2_pages WHERE pagePath='/cart/index.php' LIMIT 1</td></tr><tr><td class="db" title="PerchContent_Pages.class.php: PerchContent_Pages->find_parent_page_ids_by_path(): "> <span class="debug-badge"><span class="debug-brkt">[</span>1<span class="debug-brkt">]</span></span> SELECT pageID FROM perch2_pages WHERE  pageTreePosition IN ('000-011', '000') ORDER BY pageTreePosition DESC</td></tr><tr><td class="template" title="PerchContent_Pages.class.php: PerchContent_Pages->_template_nav(): "> <span class="debug-badge"><span class="debug-brkt">[</span>1<span class="debug-brkt">]</span></span> Using template: /templates/navigation/main_navigation.html</td></tr><tr><td class="db" title="PerchContent_Pages.class.php: PerchContent_Pages->get_navigation(): "> <span class="debug-badge"><span class="debug-brkt">[</span>1<span class="debug-brkt">]</span></span> SELECT pageID, pageParentID, pageDepth, pageTreePosition FROM perch2_pages WHERE pagePath='/linkedin-profiles' OR pageSortPath='/linkedin-profiles' LIMIT 1</td></tr><tr><td class="db" title="PerchContent_Pages.class.php: PerchContent_Pages->get_navigation(): "> <span class="debug-badge"><span class="debug-brkt">[</span>1<span class="debug-brkt">]</span></span> SELECT * FROM perch2_pages WHERE pageNew=0  AND pageHidden=0  AND pageTreePosition LIKE '000-003%'  AND pageDepth &gt;=1 AND pageDepth&lt;=2  ORDER BY pageTreePosition ASC</td></tr><tr><td class="db" title="PerchDB_MySQL.class.php: PerchDB_MySQL->get_value(): "> <span class="debug-badge"><span class="debug-brkt">[</span>1<span class="debug-brkt">]</span></span> SELECT pageTreePosition FROM perch2_pages WHERE pagePath='/cart/index.php' LIMIT 1</td></tr><tr><td class="db" title="PerchContent_Pages.class.php: PerchContent_Pages->find_parent_page_ids_by_path(): "> <span class="debug-badge"><span class="debug-brkt">[</span>1<span class="debug-brkt">]</span></span> SELECT pageID FROM perch2_pages WHERE  pageTreePosition IN ('000-011', '000') ORDER BY pageTreePosition DESC</td></tr><tr><td class="template" title="PerchContent_Pages.class.php: PerchContent_Pages->_template_nav(): "> <span class="debug-badge"><span class="debug-brkt">[</span>1<span class="debug-brkt">]</span></span> Using template: /templates/navigation/main_navigation.html</td></tr><tr><td class="db" title="PerchContent_Pages.class.php: PerchContent_Pages->get_navigation(): "> <span class="debug-badge"><span class="debug-brkt">[</span>1<span class="debug-brkt">]</span></span> SELECT pageID, pageParentID, pageDepth, pageTreePosition FROM perch2_pages WHERE pagePath='/interview-coaching' OR pageSortPath='/interview-coaching' LIMIT 1</td></tr><tr><td class="db" title="PerchContent_Pages.class.php: PerchContent_Pages->get_navigation(): "> <span class="debug-badge"><span class="debug-brkt">[</span>1<span class="debug-brkt">]</span></span> SELECT * FROM perch2_pages WHERE pageNew=0  AND pageHidden=0  AND pageTreePosition LIKE '000-005%'  AND pageDepth &gt;=1 AND pageDepth&lt;=2  ORDER BY pageTreePosition ASC</td></tr><tr><td class="db" title="PerchDB_MySQL.class.php: PerchDB_MySQL->get_value(): "> <span class="debug-badge"><span class="debug-brkt">[</span>1<span class="debug-brkt">]</span></span> SELECT pageTreePosition FROM perch2_pages WHERE pagePath='/cart/index.php' LIMIT 1</td></tr><tr><td class="db" title="PerchContent_Pages.class.php: PerchContent_Pages->find_parent_page_ids_by_path(): "> <span class="debug-badge"><span class="debug-brkt">[</span>1<span class="debug-brkt">]</span></span> SELECT pageID FROM perch2_pages WHERE  pageTreePosition IN ('000-011', '000') ORDER BY pageTreePosition DESC</td></tr><tr><td class="template" title="PerchContent_Pages.class.php: PerchContent_Pages->_template_nav(): "> <span class="debug-badge"><span class="debug-brkt">[</span>1<span class="debug-brkt">]</span></span> Using template: /templates/navigation/main_navigation.html</td></tr><tr><td class="db" title="PerchContent_Pages.class.php: PerchContent_Pages->get_navigation(): "> <span class="debug-badge"><span class="debug-brkt">[</span>1<span class="debug-brkt">]</span></span> SELECT pageID, pageParentID, pageDepth, pageTreePosition FROM perch2_pages WHERE pagePath='/corporate-services' OR pageSortPath='/corporate-services' LIMIT 1</td></tr><tr><td class="db" title="PerchContent_Pages.class.php: PerchContent_Pages->get_navigation(): "> <span class="debug-badge"><span class="debug-brkt">[</span>5<span class="debug-brkt">]</span></span> SELECT * FROM perch2_pages WHERE pageNew=0  AND pageHidden=0  AND pageTreePosition LIKE '000-006%'  AND pageDepth &gt;=1 AND pageDepth&lt;=2  ORDER BY pageTreePosition ASC</td></tr><tr><td class="db" title="PerchDB_MySQL.class.php: PerchDB_MySQL->get_value(): "> <span class="debug-badge"><span class="debug-brkt">[</span>1<span class="debug-brkt">]</span></span> SELECT pageTreePosition FROM perch2_pages WHERE pagePath='/cart/index.php' LIMIT 1</td></tr><tr><td class="db" title="PerchContent_Pages.class.php: PerchContent_Pages->find_parent_page_ids_by_path(): "> <span class="debug-badge"><span class="debug-brkt">[</span>1<span class="debug-brkt">]</span></span> SELECT pageID FROM perch2_pages WHERE  pageTreePosition IN ('000-011', '000') ORDER BY pageTreePosition DESC</td></tr><tr><td class="template" title="PerchContent_Pages.class.php: PerchContent_Pages->_template_nav(): "> <span class="debug-badge"><span class="debug-brkt">[</span>1<span class="debug-brkt">]</span></span> Using template: /templates/navigation/main_navigation.html</td></tr></tbody></table>
Drew McLellan

Drew McLellan 2638 points
Perch Support

Ok - I'll have to run that HTML back into a browser.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Are you calling perch_shop_empty_cart() to empty the cart?

If not, the cart still exists, it just has nothing in it. The discount is still applied.

If you call perch_shop_empty_cart() then the cart is destroyed and the discount goes along with it.

Hi,

Drew, I have the same problem. The path looks like this:

  1. Cart is empty
  2. Add a product to the cart
  3. Set a discount code
  4. In the cart I have one product and an active discount
  5. I remove the product
  6. Cart is empty
  7. I add any product to cart
  8. Previously used discount code becomes active again - why? Whether he should be removed from the cart along with the recently removed a product?