Bigcommerce Stencil Common Product Card Model has_

2019-09-17 17:28发布

According to the documentation, there is a has_options attribute on the Common Product Card Model that should return a boolean showing whether or not the product has options.

However, this value is returning false for all of my products, even though they have options. For example, if I access the homepage in debug mode via this url:

http://localhost:3000/?debug=context

One of the products under the featured products section is:

{
    "id": 114,
    "name": "Product Name",
    "url": "http://www.example.com/product-url",
    "brand": null,
    "rating": 5,
    "availability": "Usually ships the next business day",
    "summary": "Product summary goes here",
    "image": {
        "data": "https://cdn2.bigcommerce.com/server2100/abcdef/images/stencil/{:size}/products/114/8086/product_image.jpg?c=2",
        "alt": ""
    },
    "date_added": "January 6, 2014",
    "qty_in_cart": 0,
    "pre_order": false,
    "has_options": false,
    "show_cart_action": false,
    "add_to_wishlist_url": "/wishlist.php?action=add&product_id=114",
    "price": {
    "without_tax": {
        "formatted": "$19.99",
        "value": 19.99
    },
    "rrp_without_tax": {
        "formatted": "$24.99",
        "value": 24.99
    },
    "saved": {
        "formatted": "$5.00",
        "value": 5
    },
    "tax_label": "Tax"
    }
}

As you can see has_options is false. However, this product does have options. Via the control panel, I can see that it has a color swatch option. I can also see this by navigating to the products page in debug mode at http://localhost:3000/product-url?debug=context. As you can see, part of the output contains the options information for that product:

"options": [
    {
        "id": 498,
        "type": "Configurable_PickList_Swatch",
        "display_name": "Color",
        "required": true,
        "condition": true,
        "values": [
            {
                "label": "Powder Coat Black",
                "id": 390,
                "data": [
                    "000000"
                ],
                "selected": false
            },
            {
                "label": "Anodized Aluminum",
                "id": 391,
                "data": [
                    "D9D9D9"
                ],
                "selected": false
            }
        ],
        "partial": "swatch"
    }
],

As you can see, the product does in fact have options, yet the Common Product Card Model for this product shows has_options as false.

Is there some other setting that is effecting the output of has_options? Why would it be showing false for a product that has options?

标签: bigcommerce
1条回答
Deceive 欺骗
2楼-- · 2019-09-17 18:02

has_options is used to denote something is purchasable (true) or not (false). This is misleading and documentation will be revised to reflect this.

查看更多
登录 后发表回答