Bigcommerce模板' theme_settings'在生产中的ajax请求期间不可用

时间:2016-06-25 01:30:37

标签: bigcommerce

我在inRange(src, CvScalar(0,0,0),CvScalar(50,50,50),dest); 中定义了一些自定义送货方式名称,如下所示:

config.json

在我的{ "settings": { "shipping_methods": { "Free Shipping": { "display_name": "Free Shipping", "transit_time": "2-5 Business Days" }, "UPS Ground and 3 Day Select (Ground)": { "display_name": "UPS Ground", "transit_time": "1-5 Business Days" }, "UPS Ground and 3 Day Select (3 Day Select)": { "display_name": "UPS 3 Day Select", "transit_time": "3 Business Days" }, "UPS 2nd Day Air and Next Day (2nd Day Air)": { "display_name": "UPS 2nd Day Air", "transit_time": "2 Business Days" }, "UPS 2nd Day Air and Next Day (Next Day Air)": { "display_name": "UPS Next Day Air", "transit_time": "Next Business Day" } } } } 文件中,我循环使用这些送货方式,以便调整系统返回的送货方式,如下所示:

templates/components/cart/shipping-quotes.html

这在开发中非常有效。但是,当我将主题上传到实体店时,我的运费报价总是空白。

在对此进行调查之后,我发现在实体商店中,当商店进行ajax调用以检索送货报价时,上下文中不存在<form> {{#if quotes.shipping_methods}} <table class="shippingEstimator-list"> <tbody> {{#each quotes.shipping_methods}} {{#with (lookup ../theme_settings.shipping_methods provider_name)}} <tr class="shippingEstimator-item"> <td class="shippingEstimator-method"> <div class="shippingEstimator-name"> {{display_name}} </div> <div class="shippingEstimator-time"> {{transit_time}} </div> </td> <td class="shippingEstimator-price"> {{../cost.formatted}} </td> <td class="shippingEstimator-select"> <button class="button primary hollow expanded" data-select-shipping-quote="{{../id}}">Select</button> </td> </tr> {{/with}} {{/each}} </tbody> </table> {{/if}} </form> 对象。

为什么theme_settings对象在生产中不可用于ajax请求?这似乎是一个相当严重的错误。

2 个答案:

答案 0 :(得分:0)

您是否在schema.json文件中添加了这些设置对象的条目?如果config.json文件中的条目映射到主题的schema.json文件中,则它们仅公开给主题编辑器。

查看相关文档here

答案 1 :(得分:0)

在shipping-quotes.html文件的YAML标记中提供元数据不是更好吗?

根据我的理解,这里不需要config.json和schema.json文件,因为我们不会尝试将其添加到主题设置框中。

另一方面,我可能更倾向于使用javascript注入并通过webdav托管javascript文件,您可以更轻松地访问它。我不能想象每次你想要改变措辞或转机时间时都要重新上传主题。

<!-- templates/components/cart/shipping-quotes.html -->

---
shipping_methods_meta:
    "Free Shipping": 
        - display_name: "Free Shipping"
          transit_time: "2-5 Business Days"
    "UPS Ground and 3 Day Select (Ground)":
        - display_name: "UPS Ground"
          transit_time: "1-5 Business Days"
    "UPS Ground and 3 Day Select (3 Day Select)":
        - display_name: "UPS 3 Day Select"
          transit_time: "2 Business Days"
---

<form>
{{#if quotes.shipping_methods}}
    <table class="shippingEstimator-list">
        <tbody>
            {{#each quotes.shipping_methods}}
            {{#with (lookup shipping_methods_meta provider_name)}}
            <tr class="shippingEstimator-item">
                <td class="shippingEstimator-method">
                    <div class="shippingEstimator-name">
                        {{display_name}}
                    </div>
                    <div class="shippingEstimator-time">
                        {{transit_time}}
                    </div>
                </td>
                <td class="shippingEstimator-price">
                    {{../cost.formatted}}
                </td>
                <td class="shippingEstimator-select">
                    <button class="button primary hollow expanded" data-select-shipping-quote="{{../id}}">Select</button>
                </td>
            </tr>
            {{/with}}
            {{/each}}
        </tbody>
    </table>
{{/if}}
</form>