2016-06-28 69 views
0

我目前看到与产品页面绑定的{{product.sku}}。类别页面上的Bigcommerce模板SKU编号

我需要显示类别/搜索页面上的SKU号码,但没有全局属性。

编辑模板>组件>产品> card.html

如果您知道任何解决方案或点我在正确的方向,这将是一个帮助。

感谢你提前:)

+0

如果你的店是活的,文章的网址为类别页面,我会告诉你如何使用Ajax加载的SKU。 – 2016-06-30 07:50:59

+0

这是客户的直播网址:http://festoolshop.ca/power-tools/drills/ –

+0

@suhdo你能找到解决方案吗? –

回答

0

你可以做一个ajax的load()调用这些信息,你需要在页面上拉,但目前不是由产品卡到暴露的辅助或数据支持这一点。

+0

我在下面试过但没有运气... $('mydiv')。load('{{url}}#sku-value'); –

1

下面是一个针对您的网站定制的示例,介绍如何从每个产品页面加载SKU,然后将其插入到类别页面。此代码应该放在类别页面上。这仅仅是一个例子,你可能需要修改它才能在你的网站上运行。

// For Each Product... 
$('.product').each(function(i) { 
    // Get the product URL 
    var url = $('> article > figure > a', this).attr('href'); // http://screencast.com/t/qBgwszhhpFiz 

    // Perform GET 
    getProductSKU(url).then(function(sku) { 
    console.log(sku); 
    // do something with the sku 
    // such as append it to the product, maybe above the 'add to cart button' 
    }); 

}); 

/** 
* Performs HTTP Get to a given product page 
* and returns the SKU on that page. 
* @param url <string> - The product URL to GET 
* @return Promise - Resolved with product SKU on success. 
*/ 
function getProductSKU(url) { 
    return new Promise(function(resolve, reject) { 
    $.ajax({ 
     url: url, 
     type:'GET', 
     success: function(data){ 
     resolve($(data).find('#sku-value').text()); //Return the SKU - http://screencast.com/t/zlCAftmekgp 
     }, 
     error: reject 
    }); 
    }); 
} 

链接:
http://screencast.com/t/qBgwszhhpFiz
http://screencast.com/t/zlCAftmekgp

+0

谢谢!试图通过模具应用找到一种方法,但没有。愚蠢的是,我没有办法使产品色板从类别页面保留到产品页面。您现在可以更改产品网格上的颜色,并转到以相同颜色着陆的产品页面。 :d –