Jump to content

Refresh cart prices when I add a specific price rule


Lorem Ipsum

Recommended Posts

Hi!

 

I have a module that add a product to cart with a specific price rule so the customer only pay a specific price and not the product price.

The plugin is working well, the only thing is, when I create my specific price rule, I redirect the customer to the shopping cart and it displays the product price, not the specific price, I have to refresh after a moments and then only it displays the specific price.

There must be a cache somewhere for this but I can't find it...

Any idea?

 

Thanks!

Link to comment
Share on other sites

  • 1 year later...
  • 10 months later...
  • 11 months later...
  • 7 months later...

Hello @Abdulla CM, @bollydow, @Lorem Ipsum, @IronMan0803 :) I have similar problem but I try like code bellow:


Cache::clear();
$specific_price->flushCache();
Tools::generateIndex();
DB::getInstance()->execute('RESET QUERY CACHE;');
DB::getInstance()->execute('FLUSH QUERY CACHE;');
$cart->resetStaticCache();
$cart->update();

 

of course without the success 

Edited by polo195pl (see edit history)
Link to comment
Share on other sites

Well after talk with @Krystian Podemski (thx for help) we found simple solution for this :)
it was enough to change the date from the from field to 0000-00-00 00:00:00
So code for new specific price look now: 
 

$specific_price = new SpecificPrice();
$specific_price->id_product = $id_product; // choosen product id
$specific_price->id_product_attribute = $id_product_attribute; // optional or set to 0
$specific_price->id_cart = $id_cart;
$specific_price->from_quantity = $quantity;
$specific_price->price = $price;
$specific_price->reduction_type = 'amount';
$specific_price->reduction_tax = 1;
$specific_price->reduction = 0;
$specific_price->from = date("0000-00-00 00:00:00");
$specific_price->to = date("Y-m-d H:i:s", strtotime('+1 year')); // or set date x days from now
$specific_price->id_shop = $id_shop;
$specific_price->id_currency  = $id_currency;
$specific_price->id_country = 0;
$specific_price->id_group = 0;
$specific_price->id_customer = 0;
$specific_price->add();

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...