• Resolved waleednasir1024

    (@waleednasir1024)


    hello i have 2 issues, the first one is that i have 2 delivery methods local pickup and free shipping but after installing this plugin i am only showed local pickup shipping regardless if i disable the service types or select deliver.

    the second issue is i want to hide the address fields if pickup is selected but i cant seem to get the value from service type field for some reason with this code

    add_filter('woocommerce_checkout_fields', 'xa_remove_billing_checkout_fields');
    
    function xa_remove_billing_checkout_fields($fields) {
        $service_method ='pickup'; 
        global $woocommerce;
        $chosen_methods = WC()->checkout->get_value( 'wfs_service_type' );
        $chosen_service = $chosen_methods[0];
    
        if ($chosen_service == $service_method) {
            unset($fields['billing']['billing_address_1']); // Add/change filed name to be hide
            unset($fields['billing']['billing_address_2']);
        }
        return $fields;
    }

    if i keep ($service_method = ”) then the fields are hidden meaning the variable is not getting any value from service type can you help or make any correction please will be really greatful

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

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

    (@wpscripts)

    Hello,

    Please change the $chosen_service to following,

    if( function_exists('wfs_get_default_service_type') ) 
    	$chosen_service = wfs_get_default_service_type();
    else 
    	$chosen_service = $_COOKIE['service_type'];

    We can’t check the URL as the website is under construction. The selection of shipping method works as follows. When pickup service is selected from the menu page, it will pick the Local pickup. If you try to change it to delivery on the checkout page itself, it won’t update until you change the address field. Because woocommerce works in this way, the shipping method stays selected until you change the address or that session is expired.

    Thanks & Regards,
    Team WP Scripts

    Plugin Author WP Scripts

    (@wpscripts)

    Hello,

    We hope the above solution worked for you. As there has been no response from your side, we are closing this ticket for now. Feel free to reply at any time.

    Thanks & Regards,
    Team WP Scripts

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Removing checkout fields based on service’ is closed to new replies.