Bigcommerce Stencil Common Product Card Model has_options attribute not working

人盡茶涼 提交于 2019-12-14 03:19:21

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/36000933/bigcommerce-stencil-common-product-card-model-has-options-attribute-not-working

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!