3

I'm wondering of the best way to tackle the development of some custom logic for a product inside Store 2.

I'm trying to update other Store fields of a project (Length, Width, Height, etc..), based on what Modifier has been selected. For example, if a user chooses Modifier A, add 3 inches onto the height; Modifier B, add 4 inches.

The Store product fieldtype doesn't provide any hooks for extension, so I'm wondering if all this should be done using other custom fields and updated on template run time, or if there is a way to hook into the product custom field and do this when a product is updated in the CMS.

Any thoughts, suggestions, or ideas would be appreciated. Thanks!

2

Since Store 2.0.4 it is possible to specify the length/width/height/weight fields dynamically at the same time the product is added to your cart, so you could implement this logic using javascript.

First you need to enable this feature under Admin > Channel Administration > Channel Fields > Products channel > Product Details field > Enable Dynamic Weight & Dimensions.

Then, inside the {exp:store:product} tag, you can submit length, width, height, and weight, and these will override the values for that particular item in the cart. You can make these hidden fields, and simply change their values using javascript when the customer changes the product options.

| improve this answer | |
  • I'm not trying to allow someone to enter them dynamically, I'm trying to have them update on the screen based on the Modifier that is selected. I need to specify the variations somewhere in the CMS and have the variables change on the front-end when the modifier changes. – Bryant Dec 14 '13 at 20:44
  • Yeah so one way to achieve that would be to store them in the CMS (using a matrix field or similar), then use the method above (with hidden fields) to handle actually applying them in the cart. Sorry I assumed the underlying reason for this was to calculate shipping based on the different dimensions - if you only need to display them then you don't need to bother with the hidden fields etc. – Adrian Macneil Dec 15 '13 at 1:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.