Page 1 of 1

Checkout disabled?

Posted: 16 Nov 2015, 18:29
by swpierce
I wrote a plugin to automatically discount products in the basket based on quantity. Everything works except that once I've updated the price of the item in the basket, the checkout button disappears.

I'd prefer not to use a coupon. Basically, we have 5 or 6 different product types in the store. For 2 of those types, the price per item goes down based on the total quantity of that type item in the basket.

Example:
Products A, B, and C are type widget and cost $1.95.
Product D is type thingy and costs $5.00.

User adds Product A to basket. $1.95. (quantity 1 of type widget)
User adds Product D to basket. No price changes. (quantity 1 of type widget)
User adds Product B to basket. Price for Products A and B in basket should both now be $1.80. (quantity 2 of type widget)
User updates quantity of Product A in basket to 2. Price for products A and B should now both be $1.65. (quantity 3 of type widget)
User removes Product B from basket. Price for Product A should now be $1.80. (quantity 2 of type widget)
User updates quantity of Product A in basket to 1. Price for product A should now be $1.95 (quantity 1 of type widget).

I'm using something along the lines of:

Code: Select all

$product->getPrice()->setValue($newPrice);
I get the feeling I should be modifying the price a different way? Is there a way to do this without making the Checkout button disappear?

Re: Checkout disabled?

Posted: 16 Nov 2015, 22:07
by aimeos
swpierce wrote: I get the feeling I should be modifying the price a different way? Is there a way to do this without making the Checkout button disappear?
The checkout button only disappears if another plugin returns false for the check.before or check.after events. The BasketLimits plugin does this for example. Simply disable all plugins you don't need in the admin interface.

Re: Checkout disabled?

Posted: 16 Nov 2015, 22:28
by swpierce
Got it. Didn't think about the other plugins. The problem was the ProductPrice plugin. Assuming it was returning false because I was changing the prices.

Haven't got to the point of dealing with saved/abandoned baskets yet. It would be nice to have the ProductPrice plugin work in case a product's price changed between when the customer saved the cart and when they came back to buy. I'll have to see if I can figure out a way to make it work without interfering with our quantity discount plugin.

Thanks!

Re: Checkout disabled?

Posted: 16 Nov 2015, 23:26
by aimeos
swpierce wrote: Haven't got to the point of dealing with saved/abandoned baskets yet. It would be nice to have the ProductPrice plugin work in case a product's price changed between when the customer saved the cart and when they came back to buy. I'll have to see if I can figure out a way to make it work without interfering with our quantity discount plugin.
A problem is that your discount is based on the quantity of several products. If the discount would based on single products, you could use the block pricing instead.

Re: Checkout disabled?

Posted: 17 Nov 2015, 05:06
by swpierce
Very true. Our customers never buy more than 1 of a given product in any shopping session, though. They do, however, buy multiple products in every shopping session. The block pricing won't work for us. We'll definitely come up with a solution though. :)