logo
Tags down

shadow

Change postcode shipping field to a dropdown in Woocommerce


By : Raviraj Gohil
Date : October 14 2020, 02:15 PM
Does that help There is multiple ways to do it:
1) For shipping postcode field only, you will use the following:
code :
add_filter( 'woocommerce_shipping_fields' , 'customize_shipping_postcode_field' );
function customize_shipping_postcode_field( $shipping_fields ) {

    $shipping_fields['shipping_postcode']['type'] = 'select';
    $shipping_fields['shipping_postcode']['options'] = array(
        ''         => __('Select your postcode', 'woocommerce'),
        'option_1' => 'Choice 1',
        'option_2' => 'Choice 2',
        'option_3' => 'Choice 3'
    );

    return $shipping_fields;
}
add_filter( 'woocommerce_default_address_fields' , 'customize_postcode_fields' );
function customize_postcode_fields( $adresses_fields ) {

    $adresses_fields['postcode']['type'] = 'select';
    $adresses_fields['postcode']['options'] = array(
        ''         => __('Select your postcode', 'woocommerce'),
        'option_1' => 'Choice 1',
        'option_2' => 'Choice 2',
        'option_3' => 'Choice 3'
    );

    return $adresses_fields;
}


Share : facebook icon twitter icon

WooCommerce: get and set shipping & billing address's postcode


By : Vitor Mateus
Date : March 29 2020, 07:55 AM
I wish this helpful for you You can do the following to get/set billing/shipping postcodes,
To set the values,
code :
$customer = new WC_Customer();
$customer->set_postcode('123456');     //for setting billing postcode
$customer->set_shipping_postcode('123456');    //for setting shipping postcode
$shipping_postcode = get_user_meta( $current_user->ID, 'shipping_postcode', true );
$billing_postcode = get_user_meta( $current_user->ID, 'billing_postcode', true );

How to update shipping calculations on change of custom shipping field in woocommerce?


By : whistler
Date : March 29 2020, 07:55 AM
help you fix your problem This is actually extremely simple to do if you are adding your fields in the correct way(using the woocommerce_checkout_fields filter). The only thing you need to do is to add the classes address-field and update_totals_on_change like this:
code :
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );

function custom_override_checkout_fields( $fields ) {

    $fields['shipping']['custom_field'] = array(
        'label' => 'Custom field',
        'required' => 1,
        'class' => array ('address-field', 'update_totals_on_change' )
    );

    return $fields;
} 

Make checkout shipping postcode field not required in Woocommerce


By : Acwg acwg
Date : March 29 2020, 07:55 AM
I hope this helps .
That happens because you are using woocommerce_billing_fields hook filter that is managing only billing fields for a shipping postcode field…
code :
add_filter( 'woocommerce_default_address_fields', 'customise_postcode_fields' );
function customise_postcode_fields( $address_fields ) {
    $address_fields['postcode']['required'] = false;

    return $address_fields;
}

Dynamic shipping methods change by custom checkout select field in Woocommerce


By : lichuang
Date : March 29 2020, 07:55 AM
wish of those help Update 2
First, woocommerce_checkout_before_billing doesn't exist… So it could be:
code :
add_action( 'woocommerce_checkout_billing', 'before_billing_fields', 5 );
function before_billing_fields(){
    $checkout = WC()->checkout;

    woocommerce_form_field('delivery_method', array(
        'type' => 'select',
        'options'       => array(
            'blank'     => __( 'Select a delivery method', 'sdm' ),
            'shipping-by-post'  => __( 'Shipping by post', 'sdm' ),
            'shipping-by-email' => __( 'Shipping by email (evoucher)', 'sdm' )
        ),
        'class' => array('delivery_method form-row-wide'),
        'clear'     => true
    ), $checkout->get_value('delivery_method'));

    // Set the default shipping method on load: "Standard" flat rate
    WC()->session->set('chosen_shipping_methods', array('flat_rate:9'));
}
// The Jquery script
add_action( 'wp_footer', 'custom_checkout_script' );
function custom_checkout_script() {
    // Only on checkout page
    if( ! is_checkout() && is_wc_endpoint_url( 'order-received' ) )
        return;
    ?>
    <script type="text/javascript">
        jQuery( function($){
            var a = 'select#delivery_method',
                b = 'input[name^="shipping_method[0]"]',
                c = '#shipping_method_0_',
                d = 'flat_rate9', // Default flat Id
                e = 'free_shipping10', // Free shipping Id
                f = 'free_shipping:10'; // Free shipping rate Id

            // Live action event: On Select "delivery_method" change
            $(a).change( function () {
                if($(this).val() == 'shipping-by-email' )
                    $(c+e).prop("checked", true);
                else
                    $(c+d).prop("checked", true);
                $( document.body ).trigger( 'update_checkout' );
            });

            // Live action event: On Shipping method change
            $( 'form.checkout' ).on( 'change', b, function() {
                // If Free shipping is not selected, we change "delivery_method" slect field to "post"
                if( $(this).val() != f )
                    $(a).val('shipping-by-post');
                else
                    $(a).val('shipping-by-email');
            });
        });
    </script>
    <?php
}

Remove postcode from Woocommerce cart shipping calculator


By : Geethaka N Kurukulas
Date : March 29 2020, 07:55 AM
will be helpful for those in need In Woocommerce I have been able to remove postcode checkout field using this code: , This can be done adding the following:
code :
add_filter( 'woocommerce_shipping_calculator_enable_postcode', '__return_false' );
Related Posts Related Posts :
  • Mongo $addToSet an Array
  • Integrating isotope.js with Wordpress loop
  • Create Admin settings for SugarCRM custom module
  • Storing special characters in DB in such a way to display properly on site and still find image with the same name
  • Obtain value tag from xml
  • PHP Mail with attachment - but file is empty
  • PHP Multiple require, same function
  • Traverse XML file to find products recursively
  • PHP is not displaying 'success' message after writing data to JSON, but data gets added
  • Locate specific text in Google Sheets using the API
  • Laravel, convert to uuid text from uuid binary upon creating model
  • Creating formula
  • Grouped Array data
  • Wordpress get_option() with index key from string
  • PHP Laravel: A better way than these if statements
  • Trying to build my query by fetching column names from the selected table
  • Two values in the same column
  • Exceeding 10 nested forwards?
  • Ternary in associative arrays in PHP
  • simplexml_load_file won't fetch data with an Array
  • php mysql looking how to check if there are no result
  • Laravel filters won't work when trying to add them
  • Checking for duplicate mysql data with bootstrap validator
  • yii2 Error of dynamic client validation URL - Cannot read property 'test' of undefined
  • PHP Script to handle end of year calculation automatically?
  • Saved html is not the same as it's output in the browser
  • Wordpress shows only one post
  • SQL record retrieval
  • PHP return true if all method calls inside a foreach method return true
  • Unexpected error after transfering website to new server - mix of php and html in IF
  • Remove the last part of the comma in foreach in PHP?
  • the_author_meta() wont show inline text in { }
  • How do I create an error handler in php that redirects the user if a specific error occurs?
  • PHPInfo / Valet - Two different PHP versions
  • Connect an active directory or LDAP with PHP
  • How to assign a variable from another file to a class constant?
  • How to remove array index from php array?
  • How to handle multiple paginations with one link
  • Inverting order of exhibition of the elements in PHP
  • Slim 3 withRedirect problem and parameters
  • using Laravel 5.7 : how can i get json value name from an array ?
  • I See a Lot of `<open></close>` Tag Sets That Contain NO Data, Doesn't This Negate the Tag?
  • Calling a class and function using variable
  • php unset foreach loop is not unsetting the value of array
  • Error! The command "tesseract" was not found. (PHP thiagoalessio)
  • Get the catalog visibility for a product in a SQL query on Woocommerce
  • show data from json
  • Laravel - Views - router() doesn't work or I just dumb
  • Return foreach values inside string
  • Internal server error 500 Laravel 5.4 AJAX
  • Add text to a file with PHP SSH2
  • Setting up named routes within a subdomain group in Laravel 5.7
  • Yii2: How to add two fields and NULLS LAST in orderby() of Find() using mysql
  • Removing string characters form mysqli database and utilize two variables derived from database
  • How to update one table from two different pages in laravel
  • Select non-parentheses and non-quotes comma
  • How to filter php array by min/max value
  • how to send an array of URI's from php to python and print it there
  • Php 7.1 Return Type-hint failing in Laravel 5.7
  • Validation in Laravel 5.6
  • shadow
    Privacy Policy - Terms - Contact Us © voile276.org