New Landing How can we help? Atelier Price display on variable products

Viewing 9 posts - 1 through 9 (of 9 total)
  • Posted in: Atelier
  • #202703
    LEQUIE
    Member
    Post count: 40

    Hello there,

    I have a question about variable products.

    I would like to define the property “size” as a variable. Let’s say, “small” costs 10€ and “large” costs 20€.

    I have the following problems now:
    1. In the product listing appears “10.00€-20.00€”. That’s not very pretty, I would rather have “from 10,00€” or just “10.00€”. How do I get that?
    2. In the product view itself there is a similar problem with the price. There is always only “10,00-20,00€”, no matter what size I choose. I would like to have an updated price on the product page, depending on the size i choose.

    Thanks for the help

    #202708
    Kyle – SUPPORT
    Moderator
    Post count: 35880

    Hi

    1) Add this to your child theme’s functions.php file:

    // Use WC 2.0 variable price format
    add_filter( 'woocommerce_variable_sale_price_html', 'wc_wc20_variation_price_format', 10, 2 );
    add_filter( 'woocommerce_variable_price_html', 'wc_wc20_variation_price_format', 10, 2 );
    function wc_wc20_variation_price_format( $price, $product ) {
    $min_price = $product->get_variation_price( 'min', true );
    $max_price = $product->get_variation_price( 'max', true );
    if ($min_price != $max_price){
    $price = sprintf( __( 'From %1$s', 'woocommerce' ), wc_price( $min_price ) );
    return $price;
    } else {
    $price = sprintf( __( '%1$s', 'woocommerce' ), wc_price( $min_price ) );
    return $price;
    }
    }

    2) When you have chosen your variables, a new price should appear lower down, if this doesn’t happen for you please provide me with a link to the product so I can check

    – Kyle

    #202777
    LEQUIE
    Member
    Post count: 40

    Hi Kyle,

    thank you for the very fast response!

    Now i have 2 more problems:
    1. The text from <small class=”woocommerce-price-suffix”> is not displayed anymore for variable products in product listing. In my case it is “inkl. MwSt.” I could add it manually in your previous filter function, but then it is not formatted correctly, could you help me at this point?

    2. The Sale Price (for variabel products) is currently not displayed correctly. Although one sees the Sale Price (lowest) but it is not red, and the crossed-standard-Price is not visible. //EDIT: I could fix this point

    p.s. The price on the product view is displayed below, but i did some custom changes earlier so i will debug it alone, if i need help here i will get back to you.

    site: https://lequie.de/shop

    #202800
    LEQUIE
    Member
    Post count: 40

    Can’t edit anymore.. the //EDIT: fixed it note at point 2 shouldn’t be there, it belongs to the p.s. point, sorry…

    #202843
    LEQUIE
    Member
    Post count: 40

    AND it would be nice, if the “from” could have the same class or formatting as the suffix.

    #203350
    David Martin – Support
    Moderator
    Post count: 20834

    Hi,

    You can easily add your own class to the above function, see below:

    Please add in your own classes to the spans I added.

    	// Use WC 2.0 variable price format
    	add_filter( 'woocommerce_variable_sale_price_html', 'wc_wc20_variation_price_format', 10, 2 );
    	add_filter( 'woocommerce_variable_price_html', 'wc_wc20_variation_price_format', 10, 2 );
    	function wc_wc20_variation_price_format( $price, $product ) {
    	$min_price = $product->get_variation_price( 'min', true );
    	$max_price = $product->get_variation_price( 'max', true );
    	if ($min_price != $max_price){
    	$price = sprintf( __( '<span class="">From %1$s</span>', 'woocommerce' ), wc_price( $min_price ) );
    	return $price;
    	} else {
    	$price = sprintf( __( '<span class="">%1$s</span>', 'woocommerce' ), wc_price( $min_price ) );
    	return $price;
    	}
    	}

    Thanks,
    David.

    #203393
    LEQUIE
    Member
    Post count: 40

    Hi,

    ok this maybe helps me with point 1 (i will test it tomorrow), but i still need help on point 2.

    Thanks 🙂

    #203526
    LEQUIE
    Member
    Post count: 40

    Ok i could solve point 1, thanks for the help here.

    point 2 is still open.

    #203536
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Hi,
    I need wordpress admin login detail to check and resolve the issue.
    Thanks
    Mohammad

Viewing 9 posts - 1 through 9 (of 9 total)

You must be logged in and have valid license to reply to this topic.

License required for one of the following items
Login and Registration Log in · Register