Based on quantity update price recharge app subscription product page shopify
Example store link:
https://pets-buy-supplement.myshopify.com/
https://optimalpaw.com/
<script>
window.addEventListener('load', function() {
$(".velaQtyButton").on( 'mouseup', function() {
var cutext = $(".reg11 .money .money").text();
if( $(".rc_block__type__onetime").hasClass("rc_block__type--active") ) {
cutext = $(".rc_block__type__onetime .money").text();
} else {
cutext = $(".rc_block__type__autodeliver .money").text();
}
var newpeic = cutext.replace( "$",'' );
var count_number = $( '#qtyprod11 #Quantity[name="quantity"]' ).val();
var totalcount = (parseInt(count_number));
if( $(this).hasClass('velaQtyMinus') ) {
totalcount -= 1;
if( totalcount == 0 ){
totalcount = 1;
}
} else if( $(this).hasClass('velaQtyPlus') ) {
totalcount += 1;
}
var total = newpeic * parseInt(totalcount);
var final_text = total.toFixed(2);
$('div[class="reg11"]').html(
'Price: <span class="money"><span class="money">$'+final_text+'</span></span>'
);
});
function changePrice( $target ) {
var cutext = $target.find(".money").text();
var newpeic = cutext.replace( "$",'' );
$( '#qtyprod11 #Quantity[name="quantity"]' ).trigger( 'input' );
var count_number = $( '#qtyprod11 #Quantity[name="quantity"]' ).val();
var totalcount = (parseInt(count_number));
var total = newpeic * parseInt(totalcount);
var final_text = total.toFixed(2);
$('div[class="reg11"]').html(
'Price: <span class="money"><span class="money">$'+final_text+'</span></span>'
);
}
var err11 = document.querySelectorAll( '.rc_block.rc_block__type' );
var observer = [];
for( var i = 0; i < err11.length; i++ ) {
var err11single = err11[i];
observer[i] = new MutationObserver(function (event) {
if( $(event[0].target).hasClass( 'rc_block__type--active' ) ) {
changePrice( $(event[0].target) );
}
})
observer[i].observe( err11single, {
attributes: true,
attributeFilter: ['class'],
childList: false,
characterData: false
})
}
}, false);
</script>
Post a Comment!