WPD + DualPrice Pro integration

Please note that the price breakdown may differ on the checkout than the cart page and net order form.

Please add the below script in the theme.liquid file.

 <script>
  {% if template == "cart" or canonical_url contains "/apps/wpdapp/wholesale/wpd-net-order-cart" %}
    {% if customer.tags contains 'wpdnet' %}
      {% if shop.metafields.wcp_net.isNetEnabled == 'true' or shop.metafields.wcp_net.isNetEnabled == '1' %}
      document.addEventListener('DOMContentLoaded', function() {
        setTimeout(function(){
          if(typeof(dp_base_price_type) == 'undefined' || typeof(window.wcp_data) == 'undefined'){return false;}
          let TAX = 0;
          let OrinalPrice = 0;
          let TotalTAX = 0;
          {% for cart_Item in cart.items %}
            window.wcp_data.wcp_cart.items.forEach(function(cartItem,index){    
              if(cartItem.original_item.id == {{cart_Item.id}}){
              window.wcp_data.wcp_cart.items[index].tags = {{cart_Item.product.tags | json}};
              TAX = callFunctionDP("applyTaxRules", [jQuery, cartItem.product_id, cartItem.tags, cartItem.original_item.vendor, dp_tax_percent, dp_price_type_to_show], !0);                
              TotalTAX += (cartItem.wcp_v_price / 100) * (TAX.dpTaxPercent / 100);
              }
            });
          {% endfor %}
         
          
          
          let TotalwithTAX = 0;
          
          if(dp_base_price_type != 0){    
              OrinalPrice = parseFloat(window.wcp_data.discounted_hash.wcp_total).toFixed(2);        
          }else{
              OrinalPrice = (parseFloat(window.wcp_data.discounted_hash.wcp_total) - TotalTAX).toFixed(2);     
          }
          TotalwithTAX = (TotalTAX + parseFloat(OrinalPrice)).toFixed(2);  
          {% raw %}
          let dpWPDmoneyFormate = dp_money_format.replace("$$$", "${{").replace("$$", "{{").replace("&&", "}}");
          {% endraw %}
          let price = 0;
          {% if template == "cart" %}
            document.querySelectorAll(".net-order-prices .dualPrice").forEach(function(element){
              window.wcp_data.wcp_cart.items.forEach(function(item){
                if(Shopify.formatMoney(item.wcp_v_price, dpWPDmoneyFormate) == element.innerHTML){
                  if(dp_base_price_type == 0){   
                      TAX = callFunctionDP("applyTaxRules", [jQuery, item.product_id, item.tags, item.original_item.vendor, dp_tax_percent, dp_price_type_to_show], !0);                      
                      TAX = item.wcp_v_price * (TAX.dpTaxPercent / 100);                      
                      price = item.wcp_v_price - TAX;                      
                      element.innerHTML =  Shopify.formatMoney(price, dpWPDmoneyFormate);
                 }
                }
              });
            });

            document.querySelector("tfoot .net-order-prices").insertAdjacentHTML('afterbegin', '<div><span>Total With Tax: </span><span>'+ Shopify.formatMoney(TotalwithTAX, dpWPDmoneyFormate) +'</span></div><br/><br/>');
            document.querySelector("tfoot .net-order-prices").insertAdjacentHTML('afterbegin', '<div><span>TAX: </span><span>'+ Shopify.formatMoney(TotalTAX * 100, dpWPDmoneyFormate) +'</span></div><br/>');
            document.querySelector("tfoot .net-order-prices").insertAdjacentHTML('afterbegin', '<div><span>Orignal total: '+Shopify.formatMoney(OrinalPrice, dpWPDmoneyFormate) + '</span></div><br/>');
         
          {% elsif canonical_url contains "/apps/wpdapp/wholesale/wpd-net-order-cart"  %}

            document.querySelectorAll(".wpd-net-cart-item-price .dualPrice").forEach(function(element){
      		  window.wcp_data.wcp_cart.items.forEach(function(item){
      			if(Shopify.formatMoney(item.wcp_v_price, dpWPDmoneyFormate) == element.innerHTML){
      			  element.style.display="block";
      			  if(dp_base_price_type == 0){   
      				  TAX = callFunctionDP("applyTaxRules", [jQuery, item.product_id, item.tags, item.original_item.vendor, dp_tax_percent, dp_price_type_to_show], !0);                      
      				  TAX = item.wcp_v_price * (TAX.dpTaxPercent / 100);                      
      				  price = item.wcp_v_price - TAX;                      
      				  element.innerHTML =  Shopify.formatMoney(price, dpWPDmoneyFormate);
          		   }
      			 }
          	  });
      	   });
      	   document.querySelector(".wpd-net-cart-total-info-items .dualPrice").innerHTML = Shopify.formatMoney(OrinalPrice, dpWPDmoneyFormate);
      	   document.querySelector(".wpd-net-cart-total-info-items .dualPrice").style.display="block";
      	   document.querySelector(".wpd-net-cart-total-info-items").insertAdjacentHTML('afterend', '<div class="wpd-net-cart-total-info-items wpd-secondary-text-color"><span>Total With Tax</span><span>'+ Shopify.formatMoney(TotalwithTAX, dpWPDmoneyFormate) +'</span></div>');
      	   document.querySelector(".wpd-net-cart-total-info-items").insertAdjacentHTML('afterend', '<div class="wpd-net-cart-total-info-items wpd-secondary-text-color"><span>TAX</span><span>'+ Shopify.formatMoney(TotalTAX * 100, dpWPDmoneyFormate) +'</span></div>');
                
          {% endif %}
        },1500)
      });
      {% endif %}
    {% endif %}
  {% endif %}
</script>

Last updated