• Resolved alfredo1216

    (@alfredo1216)


    Hello,

    I have the following code which works without problem in a base installation, now when I have your plugin active the code doesn’t work.

    add_action( 'woocommerce_variable_add_to_cart', 'update_price_with_variation_price' );
     
    function update_price_with_variation_price() {
    	global $product;
    	$price = $product->get_price_html();
    	wc_enqueue_js( "		
    		$(document).on('found_variation', 'form.cart', function( event, variation ) {   
    			if(variation.price_html) $('.summary > p.price').html(variation.price_html);
    			$('.woocommerce-variation-price').hide();
    		});
    		$(document).on('hide_variation', 'form.cart', function( event, variation ) {   
    			$('.summary > p.price').html('" . $price . "');
    		});
       " );
    }

    I understand that it could be due to the modifications of FOX variables.

    This code basically modifies the price of the variable products so that a single price is displayed dynamically, and not the price range together with the price of the variable product below.

    I stay tuned and I hope you can help me.

    Greetings,

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Support mediawebster

    (@mediawebster)

    Hello

    Are you using this option? – https://share.pluginus.net/image/i20230306150403.png

    Thread Starter alfredo1216

    (@alfredo1216)

    Yes, my website uses LiteSpeed ??Cache.

    Thread Starter alfredo1216

    (@alfredo1216)

    I have already made some progress in the integration of the custom code with FOX, the code already works partially and I don’t know if the modifications are the best solution.

    add_action( 'woocommerce_variable_add_to_cart', 'update_price_with_variation_price' );
     
    function update_price_with_variation_price() {
        global $product;
    	$price = wc_price($product->get_variation_price( 'min', true )) . " – " . wc_price($product->get_variation_price( 'max', true ));
        wc_enqueue_js( "		
            $(document).on('found_variation', 'form.cart', function( event, variation ) {   
                if(variation.price_html) {
                    $('.elementor-jet-single-price.jet-woo-builder > p.price').html(variation.price_html);
                    $('.elementor-jet-single-price.jet-woo-builder .woocs_price_info').css('display', 'none');
    				$('.price .woocs_price_info').css('display', 'inline');
    				$('.woocommerce-variation.single_variation').css('display', 'none');
                }
            });
            $(document).on('hide_variation', 'form.cart', function( event, variation ) {   
                $('.elementor-jet-single-price.jet-woo-builder span.woocs_price_code').html('" . $price . "');
                $('.elementor-jet-single-price.jet-woo-builder .woocs_price_info').css('display', 'inline');
    			$('.price .woocs_price_info').css('display', 'none');
    			$('.woocommerce-variation.single_variation').css('display', 'none');
            });
        " );
    }

    Now, the problem that remains is that when changing the currency in the switch, it changes the price as it should, but when changing the variation and deselecting them, the previous currency is displayed.

    It seems that it does not respect the cache condition that FOX manages for its prices or that FOX does not redraw the price of that variable because it is not displayed yet.

    Here I share a video of what happens.

    https://app.screencast.com/XhB4tH8A7slDw

    Is there a variable that FOX handles that works in this case or a solution that you think can be used?

    Thank you,

    Plugin Support mediawebster

    (@mediawebster)

    Hello

    Please drop me exact link to the issue

    Thread Starter alfredo1216

    (@alfredo1216)

    Hello,

    If I share the link of the problem here:

    https://tuproyectoya.com/producto/familia-revit-pack-de-cerca-de-malla-ciclonica-alfajol/

    I was investigating a little more, and I found that the error occurs only when I have this option activated.

    When I deactivate it, it works perfectly. But unfortunately I cannot deactivate it since it was a solution for the issue of using LiteSpeed ??Cache.

    https://pluginus.net/support/topic/error-displaying-currency/?part=2#postid-77727

    How could I do in that case?

    Thank you.

    Plugin Support mediawebster

    (@mediawebster)

    Hello

    Looks like it’s an incompatibility with this custom product template.

    The standard function does not change this price – https://c2n.me/4i1F1eA.png – Standard function – https://share.pluginus.net/video/v20230310125533.mp4

    In your case, you need to customize the code to adapt with this third-party functionality

    Thread Starter alfredo1216

    (@alfredo1216)

    Hello,

    Done, I already solved the problems that I was presenting.

    Basically, do not use price variables, so as not to make new calls that were outside of FOX. Just use the prices that were already generated and apply visibility conditions to them and reorder them so that it works the same way.

    Thank you for your attention.

    Plugin Support mediawebster

    (@mediawebster)

    Hello

    Welcome;)

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Custom code compatibility’ is closed to new replies.