webdna / commerce-bundles

Other
3 stars 4 forks source link

Invalid purchasable ID #20

Open bluestormdesign opened 9 months ago

bluestormdesign commented 9 months ago

I have Craft 4.7, Commerce 4.4 and Commerce Bundles 2.0.0-beta.7 installed. When I click on add to basket on a bundle I get the following error "Invalid purchasable ID". I'll paste my basket code below as I might be missing something that isn't documented.

{% for bundle in craft.bundles.purchasables(product.variants).with(['bundleImage']).all()|unique %}

{{ csrfInput() }} {{ actionInput('commerce/cart/update-cart') }} {{ hiddenInput('purchasableId', bundle.id) }}
{% if bundle.bundleImage is defined and bundle.bundleImage|length %} {{ bundle.bundleImage[0].title }} {% endif %}

{{ bundle.title }}

Total price:

£{{ bundle.price|number_format(2) }}

{% set bundlePrice = bundlePrice + bundle.price %} {% endfor %}

Any help would greatly be appriciated.

DenyEs commented 8 months ago

For anyone with the same as us after an upgrade to Craft 4, you need to re-create all the bundles which will assign new purchasable IDs to them, fixing the issue when adding bundles to the cart. I will leave this issue open so it's easier to find.