Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Is there a way to either get or set the parent product on a order line set from a variant. With an order line set from a product with no variants, the productIdentifier is the main product's ID but for variant order lines it the guid for the variant and would like to be able to get the parent product or set a value on the orderline with the Id to then use to get the parent product.
The reason for this is in the cart steps i need to get and use the some of the product properties. So with the customers products some of them have got a fag to indicate their are bulk products (sold in tonnes) so the variant are the sizes e.g. 1 tonne, 2 tonne etc.
In the cart steps first i want to disable adjusting quantity for bulk products, and second is there is a bulk product in the cart show the bulk shipping option otherwise hide the bulk shipping option.
Hmm, I don't think we do, but I think you could work around this with Order Line properties https://docs.teacommerce.net/3.4.0/api/order-line/#addorupdateorderline (see example two for adding an order line with some properties).
Using this, you could set a "parentProductId" property and then you could look up the product. Or, if you just need to know if it's a bulk product, maybe store a "isBulk" property on the order line then you have no need to look up the product at all.
Hope this helps
Thanks for that, looked at the example on the order-line documentation and think am trying this wrong as my custom properties are not being set.
So just went with setting the bool direct as 1 of the properties( also saving the main products sku) like below.
<input name="properties" value="isBulk, productSku" type="hidden" />
<input name="isBulk" value=" @isProductBulk" type="hidden" />
<input name="productSku" value=" @productCode" type="hidden" />
then in the cart steps, trying to then retrieve them back like below, from the orderline, but the properties are not set.
var isBulkProduct = false;
var lineBulkFlag = false;
if (!string.IsNullOrWhiteSpace(orderLine.Properties["isBulk"]) &&
bool.TryParse(orderLine.Properties["isBulk"], out lineBulkFlag))
isBulkProduct = lineBulkFlag;
Do you have an example of how the property is actually set (given a value) or what else i need to save the value.
I think the bit you might be missing (I'm not sure as it's not present in your code snippet) is telling the AddOrUpdateOrderLine method to expect properties
<input name="AddOrUpdateOrderLine" value="productIdentifier, quantity, properties" type="hidden" />
Notice how properties is appended to the list of params for the AddOrUpdateOrderLine command.
Literally just saw that about a min ago and yep that was the missing piece :)
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted