• Resolved lpaweb

    (@lpaweb)


    Hello there,

    I need this plugin to work like the title says.
    Is there any option to make it only visible when a certain country is selected in the checkout page? For example, Portugal.

    Thanks in advance.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Here is a little code to help get you started. You can add it to your theme, or use Code Snippets plugin to add it for the frontend. It should work, but you’ll definitely want to test and double-check it.

    function show_wrap_only_for_Portugal () {
    
        if ( ! defined( 'WC_VERSION' ) || ! is_checkout() ) return;
    
        $country = WC()->session->get('customer')['shipping_country'];
        if ( empty( $country ) ){
            $country = WC()->session->get('customer')['billing_country'];
        }
        if ( empty( $country ) ) return;
    
        if ( $country == 'PT' ) return; // PORTUGAL gets wrapping
            
        // Removes wrapping for checkout (not cart) page for all OTHER countries
        remove_action( 'woocommerce_before_checkout_form', array( WC_Gift_Wrap()->wrapping, 'before_checkout_form' ) );
        remove_action( 'woocommerce_after_checkout_form', array( WC_Gift_Wrap()->wrapping, 'after_checkout_form' ) );
        
    }
    add_action( 'wp', 'show_wrap_only_for_Portugal', 50 );

    Anything more complex than this, such as also dealing with the cart, and you’ll need to consult your developer.

    Hi @lpaweb

    It’s been a week since I’ve heard from you. Is your problem solved?

    Hi again @lpaweb

    It’s been over a month since I’ve heard from you, and so I must assume you’ve solved the issue or have moved on. If you still have problems, please open a fresh support ticket. Thank you.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Only Show the Gift Option if certain country is selected’ is closed to new replies.