Closed plagasul closed 2 years ago
A third way is to modify productlist '__set' method so it adds the sorting number to a product's array when adding the product to the list.
Either directly/explicitly by adding, for example:
if (!isset($value['num'])) {
$value['num'] = $page->num();
}
...Or better by modifying the 'ww.merx.cart.fields' option related code on line Line 103. so it accepts anything that can be casted to a string. Not only a non-empty field. So we could do:
return [
'ww.merx.cart.fields' => ['num'],
];
This way we could pass even use custom methods as cart.fields as long as the output of the method can be casted to string.
Perhaps the nomenclature/concept of cart.FIELDS should also change in that case, to... I don't know what... properties ? no good suggestion here.
I could even submit a merge request for this along a test, if you may be interested @tobiasfabian
I am going to roll with the modified productlist.php for now.
Cheers
Hey @plagasul,
I’ve updated the behavior of the ww.merx.cart.fields
option as you suggested. You can try it with 1.6.0-beta.2.
Thanks for your patience.
Hello,
I'd like to show each product sorting number in the 'items' structure field of order pages.
I can think of two ways:
Pass the number as a product property when adding it to the cart and add a 'number' field to the 'items' structure field in 'order' blueprint (will only work for future orders, not those already placed)
Add the number to a field in 'product' blueprint then add that field to 'ww.merx.cart.fields' - If I understood well, this would automatically add it to the product's array in the cart- then create the corresponding field in the 'items' structure field in 'order' blueprint (same problem).
Is there perhaps any better way of doing this in MERX ?
Danke