Checkout disabled?
Posted: 16 Nov 2015, 18:29
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:
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?
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);