שינוי תצוגת מחיר במוצר עם וריאציות ל"החל מ..."

PHOTO EMBED

Tue May 18 2021 20:05:49 GMT+0000 (Coordinated Universal Time)

Saved by @Shesek

add_action('woocommerce_before_single_product', 'check_if_variable_first');
function check_if_variable_first()
{
    if (is_product()) {
        global $post;
        $product = wc_get_product($post->ID);
        if ($product->is_type('variable')) {
            // removing the price of variable products remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 ); // Variable product only if($product->is_type('variable')):

?>
            <style>
                div.woocommerce-variation-price,
                div.woocommerce-variation-availability,
                div.hidden-variable-price {
                    height: 0px !important;
                    overflow: hidden;
                    position: relative;
                    line-height: 0px !important;
                    font-size: 0% !important;
                }
            </style>
            <script>
                jQuery(document).ready(function($) {
                    $('input.variation_id').on('change',function() {
                        if ('' != $('input.c').val()) {
                            $('p.price').html($('div.woocommerce-variation-price > span.price').html()).append('<p class="availability">' + $('div.woocommerce-variation-availability').html() + '</p>');
                            console.log($('input.variation_id').val());
                        } else {
                            $('p.price').html($('div.hidden-variable-price').html());
                            if ($('p.availability'))
                                $('p.availability').remove();
                            console.log('NULL');
                        }
                    });
                });
            </script>
<?php

            echo '<p class="prrice">' . $price . '</p>
    <div class="hidden-variable-price" >' . $price . '</div>';
        }
    }
}
content_copyCOPY