Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid purchasable ID #20

Open
bluestormdesign opened this issue Feb 22, 2024 · 1 comment
Open

Invalid purchasable ID #20

bluestormdesign opened this issue Feb 22, 2024 · 1 comment

Comments

@bluestormdesign
Copy link

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) }}
    <div class="row">
        <div class="col-xs-12 col-md-6 col-md-push-6">
            {% if bundle.bundleImage is defined and bundle.bundleImage|length %}
                <img src="{{ bundle.bundleImage[0].getUrl() }}" alt="{{ bundle.bundleImage[0].title }}" class="books-bundles-bundle-image">
            {% endif %}
        </div>

        <div class="col-xs-12 col-md-6 col-md-pull-6">
            <h3>
                {{ bundle.title }}
            </h3>

            <div class="row row-flex items-end">
                <div class="col-xs-12 col-md-5">
                    <div class="books-bundles-bundle-price">
                        <p>
                            Total price:
                        </p>

                        <h4>
                            &pound;{{ bundle.price|number_format(2) }}
                        </h4>
                    </div>
                </div>

                <div class="col-xs-12 col-md-7">
                    <button id="bundle-to-cart" type="submit" class="bundle-submit">
                        Add all to basket
                    </button>
                </div>
            </div>
        </div>
    </div>
</form>

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

Any help would greatly be appriciated.

@DenyEs
Copy link

DenyEs commented Mar 27, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants