You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I use wishlist/lists/add-to-cart in a form to add a list to the cart, it throws an error:
Call to a member function indexBy() on array
Steps to reproduce
Create a list
Add items to the list
Create a form to add the list to cart
Craft CMS version
5.5.5
Plugin version
3.0.4
Multi-site?
Yes for multi-language
Additional context
I upgrade a project from Craft CMS 4.x to Craft CMS 5.x.
It worked when the project was on Craft CMS 4.x.
When I use this code in "Add to cart" form:
{% for item in list.items %} <input type="hidden" name="purchasables[{{ item.id }}][qty]" value="{{ item.quantityWished }}"> {% if item.options|length %} <input type="hidden" name="purchasables[{{ item.id }}][options][width_eighth]" value="0"> <input type="hidden" name="purchasables[{{ item.id }}][options][length_eighth]" value="0"> {% for key, value in item.options %} {% if key == 'note' %} <input type="hidden" name="purchasables[{{ item.id }}][{{key}}]" value="{{value}}"> {% else %} <input type="hidden" name="purchasables[{{ item.id }}][options][{{key}}]" value="{{value}}"> {% endif %} {% endfor %} {% endif %} {% endfor %}
It returns a Variant class element in the addToCart function of ListController.php. If I remove this code, it returns the Purchasable class element, but I got this error then, but all my product types in the CMS is related to a tax category:
craft\commerce\base\Purchasable::getTaxCategory(): Return value must be of type craft\commerce\models\TaxCategory, null returned
The text was updated successfully, but these errors were encountered:
Describe the bug
When I use
wishlist/lists/add-to-cart
in a form to add a list to the cart, it throws an error:Call to a member function indexBy() on array
Steps to reproduce
Craft CMS version
5.5.5
Plugin version
3.0.4
Multi-site?
Yes for multi-language
Additional context
I upgrade a project from Craft CMS 4.x to Craft CMS 5.x.
It worked when the project was on Craft CMS 4.x.
When I use this code in "Add to cart" form:
{% for item in list.items %} <input type="hidden" name="purchasables[{{ item.id }}][qty]" value="{{ item.quantityWished }}"> {% if item.options|length %} <input type="hidden" name="purchasables[{{ item.id }}][options][width_eighth]" value="0"> <input type="hidden" name="purchasables[{{ item.id }}][options][length_eighth]" value="0"> {% for key, value in item.options %} {% if key == 'note' %} <input type="hidden" name="purchasables[{{ item.id }}][{{key}}]" value="{{value}}"> {% else %} <input type="hidden" name="purchasables[{{ item.id }}][options][{{key}}]" value="{{value}}"> {% endif %} {% endfor %} {% endif %} {% endfor %}
It returns a Variant class element in the addToCart function of ListController.php. If I remove this code, it returns the Purchasable class element, but I got this error then, but all my product types in the CMS is related to a tax category:
craft\commerce\base\Purchasable::getTaxCategory(): Return value must be of type craft\commerce\models\TaxCategory, null returned
The text was updated successfully, but these errors were encountered: