Home Forums Themes Support Claue Discount Amount

Viewing 3 reply threads
  • Author
    Posts
    • #39506

      Hi Harry,
      Hope you are fine. 🙂

      I am using a custom code to show the discount amount on the product page:

      // Show Discount Amount on Product Page
      add_filter( 'woocommerce_get_price_html', 'change_displayed_sale_price_html', 10, 2 );
      function change_displayed_sale_price_html( $price, $product ) {
      // Only on sale products on frontend and excluding min/max price on variable products
      if( $product->is_on_sale() && ! is_admin() && ! $product->is_type('variable')){
      // Get product prices
      $regular_price = (float) $product->get_regular_price(); // Regular price
      $sale_price = (float) $product->get_price(); // Active price (the "Sale price" when on-sale)
      // "Saving price" calculation and formatting
      $saving_price = wc_price( $regular_price - $sale_price );
      // Append to the formated html price
      $price .= sprintf( __('
      <p class="saved-sale">Discount: %s</p>
      ', 'woocommerce' ), $saving_price );
      }
      return $price;
      }

      You can see this here: https://look.ir/mesauda-mascara/

      Is there any chance to customize this code to show it under the price, here: https://prnt.sc/vxh2ug

      Regards.

      Rahim Vaziri
      CEO & Founder at Look.ir

    • #39511

      Hi Rahim,

      Please add custom CSS code

      .flex.between-xs.middle-xs.price-review {
      	display: inline-block;
      }

      Kind regards

      Harry
      Premium Wordpress themes and plugins, Best WooCommerce theme https://themeforest.net/user/janstudio/portfolio?ref=janstudio

    • #39513

      Hi Harry,
      Thank you for the answer.

      After applying the code, this happens: https://prnt.sc/vxmcqa

      As I said above, I just want to bring the saved priced to the next line. Any solution for this: https://prnt.sc/vxh2ug

      Regards

      Rahim Vaziri
      CEO & Founder at Look.ir

    • #39523

      Hi Rahim,

      Please change code to

      .flex.between-xs.middle-xs.price-review {
      	display: block;
      }
      .price-review .woocommerce-product-rating {
      	float: left;
      }
      .saved-sale {
      	display: inline-block;
      }

      Kind regards

      Harry
      Premium Wordpress themes and plugins, Best WooCommerce theme https://themeforest.net/user/janstudio/portfolio?ref=janstudio

Viewing 3 reply threads

You must be logged in to reply to this topic.