I'm looking to pass back to the cart a modified 'each' price. How to do?
I have products sold by the yard. My script is taking the user-selected lengths and multiplying that by the cost/per and passing that back fine. What I'm getting for the 'each' price is the total, and I want the 'each' price to be the cost/per price.
Hence, 12 yards of $10/yard product will show a total of $120.00, and a price of $10/each.
How do I pass back the latter from my script? What do I talk to?
Thanks in advance.
So your product is 1 yard at $10. Quantity of 12 is 12 yards. Yeah?
This has actually come up before where it made a difference in terms of how the fabric was cut. So you might actually want quantity 2 of 5 yard lengths. That gets a little more involved with some javascript, but if that's what you need we could try to find that thread.
See image
Yes, I can calculate and then pass back an attribute, just need to know what the attribute is and where to do what. Thanks.
Then in your cart template, you'd loop through the fc_json.products, grab the fc_json.products[ i ].options["price_per"] and replace the html in the ".fc_cart_item_price_each" element.
Does that make sense?
I could use some code direction here. Thanks in advance.
Note that I haven't tested this, but it should work.