pinkp
pinkp

Reputation: 455

Using Big Cartel E-commerce / Shop: Require 1 item from specific product category to checkout

I'm creating a Big Cartel shop.

I need customers to add a product from a specific category to there cart to be able to checkout. In my case this is a delivery time as a product. I have these set up as products in a category called 'time' (there are other categories). I want something like the following but this doesn't work. It just always shows the button even if there is not time product item in the cart.

The BigCartel syntax and variables can be found here: https://developers.bigcartel.com/api/themes#cart

{% if cart.items_category.name == time %}
   <button type="submit" name="checkout" class="button checkout-btn">Checkout</button>
{% else %}
    Please add a product from Time to continue
{% endif %}

Upvotes: 1

Views: 202

Answers (1)

Dave
Dave

Reputation: 612

Looking at the big cartel API, the reference to cart.items_category is nonexistent. From what I see you can get the cart items using cart.items which will return all items in the cart. Then you can loop through the returned items using item.product which will return all products associated with the items in your cart, then you can do the product categories using product.categories returning all product categories used in the scope, finally that list of product categories can be compared to see if any match the name time.

Upvotes: 0

Related Questions