Replies: 3 comments 1 reply
-
I don't think I can add any parameters to that callback without causing issues for everyone else using that feature (their callbacks won't be expecting an empty parameter to be passed in, causing a PHP error). You could in theory get the cart and get the line item based on the product but obviously that won't work if you have multiple line items with the same product. 🤔 The only way I could see doing it would be adding an additional method that passes the line item instead of the product. It's a bit messy but it might be workable for now. As an aside, I'm currently working on the next version of Simple Commerce, so I'll have a think about re-working the product price hooks then. |
Beta Was this translation helpful? Give feedback.
-
Hmm how would that work? Pass a method to the hook? Wouldn't this be easier? It won't break anything to other applications.
|
Beta Was this translation helpful? Give feedback.
-
Thanks for the PR - merged & tagged! 🚀 |
Beta Was this translation helpful? Give feedback.
-
Hi Duncan,
A while back, I asked you about adding a product configurator. The product variants weren't helpful in that case, so we made use of metadata. Up until now it works great. We got all the features we need. I only got 1 small problem with calculating the price from a line item in the cart. It was here: #1059
We use the webhook function to get a custom price, but it only adds a product to the hook. Is there a way to add the lineItem that's it's calculating it for? With that, we can get the metadata from it and calculate the price on that. Now, when we have 2 the same products, but with a different configuration, it can't calculate the price properly, because we can't determine which lineItem it's requesting.
So in the LineItemCalculator, the webhook is being called:
$productPrice = (SimpleCommerce::$productPriceHook)($order, $product);
Can we add the lineItem there? Or create a webhook based on LineItem?
Something like:
$productPrice = (SimpleCommerce::$lineItemHook)($lineItem);
With this, we have everything we need, basically.
ps. if you want to take a peek, https://www.tusol.com/nl-nl/glazen-schuifwand/4-railsysteem-met-4-glaspanelen
Beta Was this translation helpful? Give feedback.
All reactions