How to display Woocommerce product price by ID number on a custom page?

后端 未结 2 516
攒了一身酷
攒了一身酷 2020-12-07 16:58

I\'m trying to display a price of a product in Woocommerce, on a custom page. There is a short code for that, but it gives product price and also adds an \"Add to cart butto

2条回答
  •  再見小時候
    2020-12-07 17:13

    In woocommerce,

    Get regular price :

    $price = get_post_meta( get_the_ID(), '_regular_price', true);
    // $price will return regular price
    

    Get sale price:

    $sale = get_post_meta( get_the_ID(), '_sale_price', true);
    // $sale will return sale price
    

提交回复
热议问题