0

My questions simple. I just want to use below javascript code into the stencil framework format

<script type="text/javascript">
$(document).ready(function() {
var CartTotal = '%%GLOBAL_CartItemTotal%%';
var CustomerGroup = '%%GLOBAL_CustomerGroupName%%';
var CartTotal = CartTotal.replace('$','');
var CartTotal = CartTotal.replace(',','');
if(CartTotal >= 100.0) {
$('.CartTotalMessage').hide();
}
else {
if (CustomerGroup == "Wholesale") {
$('.ProceedToCheckout').hide();
$('.PayPalExpressCheckout').hide();
$('#CartHeader h2 img').hide();
$('.btn-secondary').hide();
$('a[title="Click here to proceed to checkout"]').hide();
}
else {
$('.CartTotalMessage').hide();
}
}
});
</script>

It's not working in stencil format I know there is need to use objects of stencil big. format i have replaced %%GLOBAL_CartItemTotal%% into {{cart.grand_total}} and %%GLOBAL_CustomerGroupName%% into {{customer.customer_group_name}} but it's not working to hide checkout button untill order above $100 I need your help how I can achieve this.

Cœur
  • 37,241
  • 25
  • 195
  • 267
R.K.Bhardwaj
  • 2,168
  • 1
  • 14
  • 24
  • It looks like you will need to find the page elements that contain the cart total and use that to set the variable instead of a global. For customer group, you can use {{customer.customer_group_name}} or {{customer.customer_group_id}} – Alyss Apr 18 '17 at 19:20

1 Answers1

0

yes I have solved my problem convert js above like this

<script type="text/javascript">
$(document).ready(function() {
var CartTotal = '{{cart.grand_total.formatted}}';
var CartTotal = CartTotal.replace('$','');
var CartTotal = CartTotal.replace(',','');
console.log(CartTotal);
if(CartTotal >= 100.0) {
   $('.CartTotalMessage').hide();
}
else {
  $('.CartTotalMessage').show();
  $('.PayPalExpressCheckout').hide();
  $('#CartHeader h2 img').hide();
  $('.btn-secondary').hide();
  $('a[title="Click here to proceed to checkout"]').hide();
}
});

Thanks for help

R.K.Bhardwaj
  • 2,168
  • 1
  • 14
  • 24