Support » Plugin: PW WooCommerce Gift Cards » Change Label Name

  • Resolved Ravi Shankar Singh

    (@ravi-shankar-singh)


    How can i change the label name in dropdown. Instead of price in dropdown i want to show text like gold | Diamond | Platinum etc. I don’t want to show price in dropdown. and if someone selecting the option from dropdown then show price of that selected option like variable products.

    How can i achieve that?

    I am using price based country woocommerce plugin. As i entered the price in terms of INR then it’s working fine but if i am accessing the site in US it’s showing in USD currency but the label of dropdown price is not changing only currency changing.

    To understand better just select billing fields once with India and once with USA or Singapore so you”ll understand my issue.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author pimwick

    (@pimwick)

    WooCommerce has a hook that you can use to change labels for the dropdown menu. It is called woocommerce_variation_option_name

    You could then map the current value to the name you want to see. For example:

    <?php
    
    function pw_gift_cards_woocommerce_variation_option_name( $name ) {
        global $product;
    
        if ( is_a( $product, 'WC_Product_PW_Gift_Card' ) ) {
            $map = array(
                '$100' => 'Gold',
                '$500' => 'Diamond',
                '$1000' => 'Platinum',
            );
    
            if ( isset( $map[$name] ) ) {
                return $map[$name];
            }
        }
    
        return $name;
    }
    add_filter( 'woocommerce_variation_option_name', 'pw_gift_cards_woocommerce_variation_option_name', 10, 2 );

    This hasn’t been tested and you will probably have to change the map according to what is shown on your site. Let me know how it goes!

    Plugin Author pimwick

    (@pimwick)

    Marking this thread as resolved but let us know if you need anything else!

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