Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_filter( 'woocommerce_after_single_variation', 'prezzo_singola_variazione' );
- function prezzo_singola_variazione() {
- global $product;
- if( ! $product->is_type('variable') )
- return; // Only variable products
- $available_variations = $product->get_available_variations(); // Get available variations
- $default_attributes = $product->get_default_attributes(); // Get default attributes
- // Only for a unique selected variation by default
- if( ! ( sizeof($available_variations) == 1 ) )
- return;
- // Get the unique variation
- $variation = reset($available_variations);
- // Loop through
- if( reset($variation['attributes']) ) :
- ?>
- <style>
- .variations .variable-items-wrapper li {
- pointer-events: none;
- }
- </style>
- <script>
- jQuery(document).ready(function(){
- if (jQuery(window).load()) {
- jQuery(".variable-items-wrapper li").unbind("click");
- setTimeout(function() {
- jQuery(".variations_form .single_variation_wrap .price").insertBefore(".woocommerce-variation .woocommerce-variation-custom-text-field");
- }, 1000);
- } else {
- }
- });
- </script>
- <?php $result = woocommerce_template_single_price(); ?>
- <?php
- endif;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement