Title: Question about implementation
Last modified: January 31, 2022

---

# Question about implementation

 *  [jazzu](https://wordpress.org/support/users/jazzu/)
 * (@jazzu)
 * [4 years, 2 months ago](https://wordpress.org/support/topic/question-about-implementation-2/)
 * Hello!
 * The problem I’m facing is that I don’t use default WooCommerce single product
   pages, because I made custom ones. Your plugin works with default template, however,
   I need to add it to my custom made pages. I only have 5 products that I need 
   the Price per Unit for, but it’s necessary.
 * I’m using Elementor. Is there a widget that I maybe missed or is there another
   way?
 * Kind regards
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fquestion-about-implementation-2%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [Martin Mechura](https://wordpress.org/support/users/mechuram/)
 * (@mechuram)
 * [4 years, 2 months ago](https://wordpress.org/support/topic/question-about-implementation-2/#post-15311476)
 * Hi Jazzu,
 * my plugin normally works with Elementor. My plugin is hooked on WooCommerce hook**
   woocommerce_get_price_html** so if the widget in Elementor uses this hook, then
   it should be visible.
 * best regards Martin
 *  Thread Starter [jazzu](https://wordpress.org/support/users/jazzu/)
 * (@jazzu)
 * [4 years, 2 months ago](https://wordpress.org/support/topic/question-about-implementation-2/#post-15311519)
 * Hi [@mechuram](https://wordpress.org/support/users/mechuram/) !
 * Thank you for your reply. Hmm, the problem I can see right now is that I’m using
   a custom function for the price. Is there another way to add the widget? Like
   using a shortcode or something?
 * The code I’m using for the price:
 *     ```
       function custom_price_shortcode_callback( $atts ) {
   
           $atts = shortcode_atts( array(
               'id' => null,
           ), $atts, 'product_price' );
   
           $html = '';
   
           if( intval( $atts['id'] ) > 0 && function_exists( 'wc_get_product' ) ){
               // Get an instance of the WC_Product object
               $product = wc_get_product( intval( $atts['id'] ) );
   
               // Get the product prices
               $price         = wc_get_price_to_display( $product, array( 'price' => $product->get_price() ) ); // Get the active price
               $regular_price = wc_get_price_to_display( $product, array( 'price' => $product->get_regular_price() ) ); // Get the regular price
               $sale_price    = wc_get_price_to_display( $product, array( 'price' => $product->get_sale_price() ) ); // Get the sale price
   
               // Your price CSS styles
               $style1 = 'style="font-size:25px;color:#FF0000;font-weight:bold;"';
               $style2 = 'style="font-size:17px;color:#5F5F5F"';
   
               // Formatting price settings (for the wc_price() function)
               $args = array(
                   'ex_tax_label'       => false,
                   'currency'           => 'EUR',
                   'decimal_separator'  => ',',
                   'thousand_separator' => '.',
                   'decimals'           => 2,
                   'price_format'       => '%2$s&nbsp;%1$s',
               );
   
               // Formatting html output
               if( ! empty( $sale_price ) && $sale_price != 0 && $sale_price < $regular_price )
                   $html = "<del $style2>" . wc_price( $regular_price, $args ) . "</del> <ins $style1>" . wc_price( $sale_price, $args ) . "</ins>"; // Sale price is set
               else
                   $html = "<ins $style1>" . wc_price( $price, $args ) . "</ins>"; // No sale price set
           }
           return $html;
        }
        add_shortcode( 'price', 'custom_price_shortcode_callback' );
       ```
   
 * Kind regards
    -  This reply was modified 4 years, 2 months ago by [jazzu](https://wordpress.org/support/users/jazzu/).
 *  Plugin Author [Martin Mechura](https://wordpress.org/support/users/mechuram/)
 * (@mechuram)
 * [4 years, 2 months ago](https://wordpress.org/support/topic/question-about-implementation-2/#post-15311766)
 * I’m sorry, there is only a filter **mcmp_get_recalc_price** which can be used–
   no shortcode, and this filter is only in the paid version.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Question about implementation’ is closed to new replies.

 * ![](https://ps.w.org/woo-price-per-unit/assets/icon-256x256.png?rev=2269371)
 * [Price Per Unit for WooCommerce](https://wordpress.org/plugins/woo-price-per-unit/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woo-price-per-unit/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woo-price-per-unit/)
 * [Active Topics](https://wordpress.org/support/plugin/woo-price-per-unit/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woo-price-per-unit/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woo-price-per-unit/reviews/)

## Tags

 * [builder](https://wordpress.org/support/topic-tag/builder/)
 * [implementation](https://wordpress.org/support/topic-tag/implementation/)
 * [page](https://wordpress.org/support/topic-tag/page/)
 * [products](https://wordpress.org/support/topic-tag/products/)
 * [widget](https://wordpress.org/support/topic-tag/widget/)

 * 3 replies
 * 2 participants
 * Last reply from: [Martin Mechura](https://wordpress.org/support/users/mechuram/)
 * Last activity: [4 years, 2 months ago](https://wordpress.org/support/topic/question-about-implementation-2/#post-15311766)
 * Status: not resolved