Prestashop voucher box doesn't toggle and voucher codes don't work

37 Views Asked by At

Suddenly the voucher box in the cart (checkout) is not being toggled on and off so I can't add any promo code. I have meddled with its CSS and managed to make it always show, but none of my cart rules work. In the console there is no error.

I have checked and all of my cart rules are correct. The cart rules appear also in my db and are active. PS_CART_RULE_FEATURE_ACTIVE is already 1. I don't have a PayPal module. I didn't install any modules nor updated anything and yet this issue arose.

I use PrestaShop 1.7.8.8. PHP is 7.4.3.3

Below is the code of cart-voucher.tpl

{**
* 2007-2020 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <[email protected]>
    * @copyright 2007-2020 PrestaShop SA
    * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
    * International Registered Trademark & Property of PrestaShop SA
    *}
    {if $cart.vouchers.allowed}
        {block name='cart_voucher'}
            <div class="block-promo">
                <div class="cart-voucher">
                    {if $cart.vouchers.added}
                        {block name='cart_voucher_list'}
                            <ul class="promo-name card-block">
                                {foreach from=$cart.vouchers.added item=voucher}
                                    <li class="cart-summary-line">
                                        <span class="label">{$voucher.name}</span>
                                        <a href="{$voucher.delete_url}" data-link-action="remove-voucher"><i class="material-icons">&#xE872;</i></a>
                                        <div class="float-xs-right">
                                            {$voucher.reduction_formatted}
                                        </div>
                                    </li>
                                {/foreach}
                            </ul>
                        {/block}
                    {/if}

            <p>
                <a class="collapse-button promo-code-button" data-toggle="collapse" href="#promo-code" aria-expanded="false" aria-controls="promo-code">
                    {l s='Have a promo code?' d='Shop.Theme.Checkout'}
                </a>
            </p>

            <div class="promo-code collapse{if $cart.discounts|count > 0} in{/if}" id="promo-code">
                {block name='cart_voucher_form'}
                <form action="{$urls.pages.cart}" data-link-action="add-voucher" method="post">
                    <input type="hidden" name="token" value="{$static_token}">
                    <input type="hidden" name="addDiscount" value="1">
                    <input class="promo-input" type="text" name="discount_name" placeholder="{l s='Promo code' d='Shop.Theme.Checkout'}">
                    <button type="submit" class="btn btn-primary"><span>{l s='Add' d='Shop.Theme.Actions'}</span></button>
                </form>
                {/block}

                {block name='cart_voucher_notifications'}
                <div class="alert alert-danger js-error" role="alert">
                    <i class="material-icons">&#xE001;</i><span class="ml-1 js-error-text"></span>
                </div>
                {/block}
            </div>

            {if $cart.discounts|count > 0}
            <p class="block-promo promo-highlighted">
                {l s='Take advantage of our exclusive offers:' d='Shop.Theme.Actions'}
            </p>
            <ul class="js-discount card-block promo-discounts">
                {foreach from=$cart.discounts item=discount}
                <li class="cart-summary-line">
                    <span class="label"><span class="code">{$discount.code}</span> - {$discount.name}</span>
                </li>
                {/foreach}
            </ul>
            {/if}
        </div>
    </div>
    {/block}
    {/if}

I have checked cart rules, I have checked the db and ps_cart_rule_feature_active and also all modules. I think the display of the box is an issue that derives from the fact that none of the code works, since probably (I can't debug) since

 <div class="promo-code collapse{if $cart.discounts|count > 0} in{/if}" id="promo-code">

The condition in this div most likely evaluates to false so the in class isn't applied.

0

There are 0 best solutions below