Mary_Pieroszkiewicz

Untitled

Apr 6th, 2021
518
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function priceUpdate() {
  2.   var varations = JSON.parse( $( '.variations_form' ).attr( 'data-product_variations' ) );
  3.  
  4.   var selectedMaterialName = $('.tpk-material-icons li.selected').data().material
  5.  
  6.   var pricePerMeter = varations.find(el => el.attributes['attribute_rodzaj-materialu'] === selectedMaterialName).display_price;
  7.  
  8.   var photoPrice = $( '#fotolia-photo-price' ).val();
  9.   var $price = $( '.tpk-single-price-span' );
  10.   var widthVal = $( '#single-product-img-dim-w' ).val();
  11.   var heightVal = $( '#single-product-img-dim-h' ).val();
  12.  
  13.   // var area = Math.round( ( widthVal * heightVal ) / 100 ) / 100;
  14.   var area = (widthVal * heightVal / 10000 );
  15.  
  16.   $( '#image-area' ).val( area );
  17.  
  18.   var newPrice = Math.round( ( area * pricePerMeter + parseFloat( photoPrice ) ) * 100 ) / 100;
  19.  
  20.   if(area < 1) {
  21.     newPrice = pricePerMeter;
  22.   }
  23.  
  24.   $price.html( newPrice + ' zł' );
  25. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×