Jump to content

Customizing Price when adding to cart?


cpettit42

Recommended Posts

I am working on a module that handles adding Embroidery to clothing items.
The customer can add embroidery to an item if they wish. There is also a dropdown that select what type of embroidery. This determines the added price (+$3/+$5).

I have written a module that handles this. It can be view here if needed: My Store (on any product page).

However, I had to modify a lot of core files to get BlockCart, Cart, Checkout and Paypal to incorporate the optional 'Embroidered' attribute, and attach the attribute price and modify the total price.


[sorry for the long winded leadup]

My question is this: Is it possible to intercept the product from a hook while it is being added to the cart (and mabey during checkout) and to modify the cart_product before it reaches the cart (adding an attribute, conditionally modifying the price etc), all from within a module/class?

Thank you.

Link to comment
Share on other sites

I've had a look at the hooks and the only one I can see that you might be able to use is the "cart" hook, which is run whether a cart is created or updated. Try adding a function like the following to your module:

function hookCart($params)
{
   $cart = $param['cart'] ;

}

Link to comment
Share on other sites

I don't think that a 'cart' hook is going to solve it as it seems to be fired only when cart is 'altered' somehow. It doesn't fire when products or quantities are changed but for example when currency is changed.

I think this is a serious flaw as adding a product to the cart/updating quantities seems to me as the one of the most central events that can happen.

I have a similar problem: I need to prevent users from adding more than one item of the same type to their cart.

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...