Here you can see list of themes using the selector
If you're using one of these themes you need to do a few steps to connect the selector to the CPB:
In the customproductbuilder-initializer.liquid file you need to add this line (if it isn't there yet)
{{ 'customproductbuilder.js' | asset_url | script_tag }}
Be sure to have jQuery connected before the file (usually already connected in theme)
{{ 'https://code.jquery.com/jquery-3.0.0.min.js' | script_tag }}
Create an asset with name "customproductbuilder.js" and fill it in with code:
(function($) {
$(document).ready(function() {
var priceConnectedToCurrencies = {
productPriceEl: false,
newPriceEl: $('<span class="money">'),
init: function() {
this.productPriceEl = $('.cpb-product-price');
this.newPriceEl.text(this.productPriceEl.text());
this.productPriceEl.closest('.row').hide().after($('<div class="row">').append($('<div class="cpb-custom-product-price current_price">').append(this.newPriceEl)));
currencyConverter.convertCurrencies();
$('body').on('CPB_ON_OPTIONS_UPDATE', function() {
this.update();
}.bind(this));
},
update: function() {
var attributesToRemove = [];
for(var i = 0; i < this.newPriceEl[0].attributes.length; i++) {
var attr = this.newPriceEl[0].attributes[i].name;
if(attr.indexOf('data-currency') === 0) attributesToRemove.push(attr);
}
for(var i = 0; i < attributesToRemove.length; i++) {
this.newPriceEl.removeAttr(attributesToRemove[i])
}
this.newPriceEl.text(this.productPriceEl.text());
currencyConverter.convertCurrencies();
}
}
function waitForCPB() {
$('.cpb-panels-container').length ? init() : requestAnimationFrame(waitForCPB);
}
waitForCPB();
function init() {
priceConnectedToCurrencies.init();
}
});
})(jQuery);
Comments
0 comments
Please sign in to leave a comment.