Support » Plugin: WooCommerce » Displaying frontend product price in admin edit page

  • Resolved nbdevelopgreece

    (@nbdevelopgreece)


    In the frontend a discount might be triggered from a mass discount plugin.

    How can you get the price and sale price in the admin product edit page?

    Trying to display mainly for convenience and ease of check with:

    
    function get_product_sale_price(){
        global $post;
        $product = wc_get_product( $post->ID );
    	echo '<div class="product_custom_field">get_price:'.$product->get_price().' - get_sale_price:'.$product->get_sale_price().'</div>';
    }
    add_action('woocommerce_product_options_general_product_data','get_product_sale_price');
Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Support Shaun Kuschel a11n

    (@shaunkuschel)

    Automattic Happiness Engineer

    Hey @nbdevelopgreece,

    Can you elaborate a bit more about this situation and perhaps share a screenshot of the admin area that you’re wanting to see the prices? Additionally, what mass discount plugin is being used and what are the possible thresholds/triggers for the discounts to be applied?

    Thread Starter nbdevelopgreece

    (@nbdevelopgreece)

    Hey @shaunkuschel,

    Thanx for the reply! I really appreciate anyone who offers me help. I want the price right where the hook points which is in the product edit page inside the product data tab. https://prnt.sc/15qyhjn

    I am using either “Woo Discount Rules” or “Finale lite” and will pick the one that works. Usually the discount trigger is “if in a specific category then -50%” (which either plugin does when asked)

    If a sale price is set in the product ( https://prnt.sc/15r0asu ) then the “$product->get_sale_price()” returns that price, but that is not what I want. I want to get the frontend price.

    Plugin Support Con a11n

    (@conschneider)

    Automattic Happiness Engineer

    Hi there,

    I want to get the frontend price.

    How about: $product->get_price_html();
    Does that go into the right direction?

    Kind regards,

    Thread Starter nbdevelopgreece

    (@nbdevelopgreece)

    Hello @conschneider !

    How about: $product->get_price_html();
    Does that go into the right direction?

    Unfortunately not. It still returns the initial price without a discount.

    Plugin Support Thu P. a11n

    (@thup90)

    Hi there,

    This is a fairly complex development topic. I’m going to leave it open for a bit to see if anyone is able to chime in to help you out.

    I can also recommend the WooCommerce Developer Resources Portal for resources on developing for WooCommerce.

    You can also visit the WooCommerce Facebook group or the #developers channel of the WooCommerce Community Slack. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, as well.

    Plugin Author automattic

    (@automattic)

    Hi there,

    I hope you found the previous reply helpful. We haven’t heard back from you in a while, so I’m going to mark this as resolved – if you have any further questions, you can start a new thread.

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.