Luca Reghellin
Luca Reghellin

Reputation: 8103

Why are prestashop Cart Rules (Vouchers) not showing in frontend?

I successfully generated a test cart rule and assigned to my user.

I can see it both in backoffice and on the my-account page under 'my vouchers'. So we're sure it's recorderd and assigned.

What happens is that in shopping-cart page, even after loggin in with my user, I can't see any voucher field.

Digging deeper, I can say that the $discounts template var is not populated, or, simply it counts zero. So I took a look to the controller, and saw it assign it via $order->getCartRules(). And getCartRules simply reads a db table. And surprise?? The order_cart_rule table is empty. So it doesn't get populated. So what could be the problem here? Ever had same issue someone? It's a strange thing..

Probably the main question is: where/when exaclty do the cart and the rules get created/applied? I can see in FrontController the cart being created, but at that point it seems the cart rules are not setted yet.

By the way, I'm running on latest prestashop 1.6.1.4

Upvotes: 1

Views: 5851

Answers (2)

Hart
Hart

Reputation: 186

is a late answer but i noticed that if you enable paypal it has in paypal.js a line that remove not only the voucher area but also the trashcan to delete a product:

see pic: https://i.gyazo.com/403a9004aaa745a2817f11884d52346b.png

/* 1.5 One page checkout*/
var qty = $('.qty-field.cart_quantity_input').val();
$('.qty-field.cart_quantity_input').after(qty);
$('.qty-field.cart_quantity_input, .cart_total_bar, .cart_quantity_delete, #cart_voucher *').remove();

by renaming the cart_voucher to cart_voucher_2 (if you not use express checkout) and cart_quantity_delete to cart_quantity_delete_2 you will return to have your things right :)

Upvotes: 0

Indrė
Indrė

Reputation: 1136

$order->getCartRules

The function $order->getCartRules() gives you the list of cart rules applied to this order (you can find it in a table ps_order_cart_rule).

Where are all cart rules?

All cart rules are in the table ps_cart_rule.

If you have marked a cart rule as Highlight - you can see this:

Vouchers field with a hightlighted cart rule.

If you have added any cart rule to your shop - you can see this:

Vouchers field.

If you can't see Vouchers field - either you don't have any cart rules or your theme installed isn't supporting it.

Upvotes: 1

Related Questions