Advertisement
paolo_bortolotti

Singola Variazione

Jun 17th, 2021
752
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.17 KB | None | 0 0
  1. add_filter( 'woocommerce_after_single_variation', 'prezzo_singola_variazione' );
  2. function prezzo_singola_variazione() {
  3.  
  4.  
  5. global $product;
  6.  
  7. if( ! $product->is_type('variable') )
  8.     return; // Only variable products
  9.  
  10. $available_variations = $product->get_available_variations(); // Get available variations
  11. $default_attributes   = $product->get_default_attributes();   // Get default attributes
  12.  
  13. // Only for a unique selected variation by default
  14. if( ! ( sizeof($available_variations) == 1 ) )
  15.     return;
  16.  
  17. // Get the unique variation
  18. $variation = reset($available_variations);
  19.  
  20. // Loop through
  21. if( reset($variation['attributes']) ) :
  22. ?>
  23. <style>
  24. .variations .variable-items-wrapper li {
  25.   pointer-events: none;
  26. }
  27. </style>
  28. <script>
  29. jQuery(document).ready(function(){  
  30.   if (jQuery(window).load()) {
  31.     jQuery(".variable-items-wrapper li").unbind("click");
  32.     setTimeout(function() {
  33.   jQuery(".variations_form .single_variation_wrap .price").insertBefore(".woocommerce-variation .woocommerce-variation-custom-text-field");
  34.    }, 1000);
  35.     } else {
  36.     }  
  37. });  
  38. </script>
  39. <?php $result = woocommerce_template_single_price();  ?>
  40. <?php
  41. endif;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement