Support » Plugin: PW WooCommerce Gift Cards » Get Min Value of Gift Card

  • Resolved davidgrishaver


    Hi There,

    We need to access the min value of the Gift Card from in a shortcode. We do a very similar thing in the shortcode for other products and it actually worked for Gift Cards until we let the user set a price and now it returns 0.

    I see some public functions like get_pwgc_custom_amount_min but am having trouble accessing them…

    This is what we run in our shortcode for other products. Any tips on how to access the min Gift Card value?

    $product = new WC_Product( get_the_ID() );
    $price = $product->price;


Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter davidgrishaver


    answering my own question here 😉

    $minprice = get_post_field( '_pwgc_custom_amount_min', $post_id, $context );

    Plugin Author pimwick


    Hi David, I replied to this yesterday but there must have been an issue while posting. Sorry for the delay, your code technically will work but it is better to use the class method in case we change the meta_key name in the future.

    Try this instead:

    $product = wc_get_product( get_the_ID() );
    $minprice = 0;
    if ( is_a( $product, 'WC_Product_PW_Gift_Card' ) ) {
        $minprice = $product->get_pwgc_custom_amount_min();

    That code will use the WooCommerce “wc_get_product” function to get the product, and then confirm the product is a gift card before calling the function to get the minimum amount.

    Again, not sure what happened with my previous post so I hope this helps!

    Thread Starter davidgrishaver


    Oh Nice! That conditional check is actually really helpful for us to get the price for the product but if it’s a gift card get the min price instead.

    Thank you!

    Plugin Author pimwick


    Wonderful, I’m going to close this ticket but if you need anything else just let us know!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Get Min Value of Gift Card’ is closed to new replies.