• Resolved mswpuser

    (@mswpuser)


    Situation
    This concerns a custom WordPress theme, which uses a 1-page checkout page. The customer is able to change shipping methods on this checkout page, which triggers two ajax requests:

    • ?wc-ajax=update_order_review
    • ?wc-ajax=update_shipping_method

    The following code is used to re-render the shipping methods after an ajax call. (Re-rendering is required, as one of the options is local_pickup, which also displays a selectbox with the various delivery locations.)

    
    add_filter('woocommerce_update_order_review_fragments', [$this, 'add_shippingmethods_ajax'], 10);
    
    	function add_shippingmethods_ajax($data) {
    			ob_start();
    			wc_cart_totals_shipping_html();
    			$woocommerce_shipping_html = ob_get_clean();
    			$data[".woocommerce-checkout-shipping"] = $woocommerce_shipping_html ;
    			return $data;
    	}
    

    Problem:
    This worked fine with WC2.0, but WC3.0 no longer displays any shipping methods in the cart/cart-shipping.htm template. “available_methods” always seems to be null.

    The shipping methods can be loaded however by adding the following code on top of the cart-shipping.htm template:

    $Shipping = new WC_Shipping();
    $available_methods = $Shipping->get_shipping_methods();

    When submitting the form, the chosen method isn’t stored though. I’ve backtraced the code to class-wc-ajax.php update_shipping_method(). This method does seem to store the correct value using
    WC()->session->set( 'chosen_shipping_methods', $chosen_shipping_methods );
    Directly using WC()->session->get( ‘chosen_shipping_methods’ ) below this line, returns the correct chosen shipping method. This value seems to be overridden though somewhere later in the code by an empty value, but I can’t figure out where or why.

    I’ve double checked my custom cart/cart-shipping.htm template, which seems to use identical code to the original WC3 template

    I’m suspecting this is caused by a change in how shipping data is handled between WC2 and WC3. Could anyone point me in the right direction?

    
    ### WordPress Environment ###
    
    Home URL: https://localhost
    Site URL: https://localhost
    WC Version: 3.4.6
    Log Directory Writable: ?
    WP Version: 4.9.8
    WP Multisite: –
    WP Memory Limit: 256 MB
    WP Debug Mode: –
    WP Cron: ?
    Language: nl_NL
    External object cache: –
    
    ### Server Environment ###
    
    Server Info: Apache/2.4.29 (Debian)
    PHP Version: 7.1.23-2+0~20181015120514.8+stretch~1.gbpab65a0 - We raden je aan om PHP-versie 7.2 of hoger te gebruiken voor betere prestaties en beveiliging. Hoe je PHP-versie bijwerken
    PHP Post Max Size: 128 MB
    PHP Time Limit: 30
    PHP Max Input Vars: 10000
    cURL Version: 7.52.1
    OpenSSL/1.0.2l
    
    SUHOSIN Installed: –
    MySQL Version: 5.5.5-10.1.26-MariaDB-0+deb9u1
    Max Upload Size: 128 MB
    Default Timezone is UTC: ?
    fsockopen/cURL: ?
    SoapClient: ?
    DOMDocument: ?
    GZip: ?
    Multibyte String: ?
    Remote Post: ?
    Remote Get: ?
    
    ### Database ###
    
    WC Database Version: 3.4.6
    WC Database Prefix: wp_
    MaxMind GeoIP Database: ? De MaxMind GeoIP Database bestaat niet - Geolocation zal niet werken. Je kunt het handmatig downloaden en installeren vanaf https://dev.maxmind.com/geoip/geoip2/geolite2/ naar het pad: . Scrol naar beneden naar "Downloads" en download het bestand "MaxMind DB binary
    gzipped" naast "GeoLite2 Country". Vergeet GeoLite2-Country_xxxxxxxx.tar.gz niet te decomprimeren en alleen het GeoLite2-Country.mmdb bestand te uploaden.
    
    Totale databasegrootte: 14.71MB
    Database datagrootte: 12.54MB
    Database index grootte: 2.17MB
    wp_woocommerce_sessions: Data: 0.03MB + Index: 0.00MB
    wp_woocommerce_api_keys: Data: 0.00MB + Index: 0.00MB
    wp_woocommerce_attribute_taxonomies: Data: 0.00MB + Index: 0.00MB
    wp_woocommerce_downloadable_product_permissions: Data: 0.00MB + Index: 0.00MB
    wp_woocommerce_order_items: Data: 0.01MB + Index: 0.01MB
    wp_woocommerce_order_itemmeta: Data: 0.04MB + Index: 0.04MB
    wp_woocommerce_tax_rates: Data: 0.00MB + Index: 0.01MB
    wp_woocommerce_tax_rate_locations: Data: 0.00MB + Index: 0.00MB
    wp_woocommerce_shipping_zones: Data: 0.00MB + Index: 0.00MB
    wp_woocommerce_shipping_zone_locations: Data: 0.00MB + Index: 0.00MB
    wp_woocommerce_shipping_zone_methods: Data: 0.00MB + Index: 0.00MB
    wp_woocommerce_payment_tokens: Data: 0.00MB + Index: 0.00MB
    wp_woocommerce_payment_tokenmeta: Data: 0.00MB + Index: 0.00MB
    wp_woocommerce_log: Data: 0.00MB + Index: 0.00MB
    bandwidth: Data: 0.05MB + Index: 0.00MB
    bandwidthtype: Data: 0.02MB + Index: 0.00MB
    blacklist: Data: 0.02MB + Index: 0.03MB
    campaign: Data: 0.02MB + Index: 0.02MB
    dataset: Data: 0.02MB + Index: 0.02MB
    datasetcolumn: Data: 0.02MB + Index: 0.02MB
    datasetcolumntype: Data: 0.02MB + Index: 0.00MB
    datasetdata: Data: 0.02MB + Index: 0.02MB
    datatype: Data: 0.02MB + Index: 0.00MB
    display: Data: 0.06MB + Index: 0.02MB
    displaygroup: Data: 0.02MB + Index: 0.00MB
    displayprofile: Data: 0.02MB + Index: 0.00MB
    file: Data: 0.02MB + Index: 0.02MB
    group: Data: 0.02MB + Index: 0.00MB
    help: Data: 0.02MB + Index: 0.00MB
    layout: Data: 0.13MB + Index: 0.00MB
    lkcampaigngroup: Data: 0.02MB + Index: 0.03MB
    lkcampaignlayout: Data: 0.02MB + Index: 0.03MB
    lkdatasetgroup: Data: 0.02MB + Index: 0.03MB
    lkdatasetlayout: Data: 0.02MB + Index: 0.00MB
    lkdisplaydg: Data: 0.02MB + Index: 0.03MB
    lkdisplaygroupgroup: Data: 0.02MB + Index: 0.03MB
    lklayoutmedia: Data: 0.02MB + Index: 0.03MB
    lklayoutmediagroup: Data: 0.02MB + Index: 0.03MB
    lklayoutregiongroup: Data: 0.02MB + Index: 0.03MB
    lkmediadisplaygroup: Data: 0.02MB + Index: 0.00MB
    lkmediagroup: Data: 0.02MB + Index: 0.03MB
    lkmenuitemgroup: Data: 0.02MB + Index: 0.03MB
    lkpagegroup: Data: 0.02MB + Index: 0.03MB
    lktaglayout: Data: 0.02MB + Index: 0.00MB
    lktagmedia: Data: 0.02MB + Index: 0.00MB
    lkusergroup: Data: 0.02MB + Index: 0.03MB
    log: Data: 9.06MB + Index: 0.62MB
    media: Data: 0.05MB + Index: 0.00MB
    menu: Data: 0.02MB + Index: 0.02MB
    menuitem: Data: 0.02MB + Index: 0.03MB
    module: Data: 0.02MB + Index: 0.00MB
    oauth_log: Data: 0.02MB + Index: 0.08MB
    oauth_server_nonce: Data: 0.02MB + Index: 0.02MB
    oauth_server_registry: Data: 0.02MB + Index: 0.03MB
    oauth_server_token: Data: 0.02MB + Index: 0.06MB
    pagegroup: Data: 0.02MB + Index: 0.00MB
    pages: Data: 0.02MB + Index: 0.02MB
    resolution: Data: 0.02MB + Index: 0.00MB
    schedule: Data: 0.02MB + Index: 0.02MB
    schedule_detail: Data: 0.02MB + Index: 0.03MB
    session: Data: 0.00MB + Index: 0.00MB
    setting: Data: 0.02MB + Index: 0.00MB
    stat: Data: 0.09MB + Index: 0.05MB
    tag: Data: 0.02MB + Index: 0.00MB
    transition: Data: 0.00MB + Index: 0.00MB
    user: Data: 0.02MB + Index: 0.02MB
    usertype: Data: 0.02MB + Index: 0.00MB
    version: Data: 0.00MB + Index: 0.00MB
    wp_commentmeta: Data: 0.00MB + Index: 0.00MB
    wp_comments: Data: 0.01MB + Index: 0.01MB
    wp_hook_list: Data: 0.00MB + Index: 0.00MB
    wp_links: Data: 0.00MB + Index: 0.00MB
    wp_options: Data: 0.82MB + Index: 0.08MB
    wp_pay_options: Data: 0.00MB + Index: 0.00MB
    wp_pay_option_subs: Data: 0.00MB + Index: 0.00MB
    wp_pay_transactions: Data: 0.00MB + Index: 0.00MB
    wp_postmeta: Data: 0.50MB + Index: 0.20MB
    wp_posts: Data: 0.60MB + Index: 0.06MB
    wp_relevanssi: Data: 0.11MB + Index: 0.23MB
    wp_relevanssi_log: Data: 0.00MB + Index: 0.00MB
    wp_relevanssi_stopwords: Data: 0.00MB + Index: 0.00MB
    wp_termmeta: Data: 0.00MB + Index: 0.00MB
    wp_terms: Data: 0.00MB + Index: 0.00MB
    wp_term_relationships: Data: 0.00MB + Index: 0.01MB
    wp_term_taxonomy: Data: 0.00MB + Index: 0.00MB
    wp_usermeta: Data: 0.03MB + Index: 0.01MB
    wp_users: Data: 0.00MB + Index: 0.00MB
    wp_wcpdf_invoice_number: Data: 0.00MB + Index: 0.00MB
    wp_wc_download_log: Data: 0.00MB + Index: 0.00MB
    wp_wc_webhooks: Data: 0.00MB + Index: 0.00MB
    xmdsnonce: Data: 0.05MB + Index: 0.00MB
    
    ### Post Type Counts ###
    
    attachment: 218
    hrf_faq: 12
    ml-slider: 2
    nav_menu_item: 9
    page: 20
    post: 12
    product: 55
    product_variation: 22
    revision: 184
    shop_order: 32
    wccpf: 8
    wpcf7_contact_form: 1
    
    ### Security ###
    
    Secure connection (HTTPS): ?
    					Jouw winkel gebruikt geen HTTPS. Leer meer over HTTPS en SSL-certificaten.
    Hide errors from visitors: ?
    
    ### Active Plugins (15) ###
    
    Akismet Anti-Spam: door Automattic – 4.0.8
    Contact Form 7: door Takayuki Miyoshi – 5.0.4
    Easy WP SMTP: door wpecommerce
    alexanderfoxc – 1.3.7
    
    Enable Media Replace: door ShortPixel – 3.2.7
    HTML5 Responsive FAQ: door Aman Verma – 2.5.5
    Laravel DD for WordPress: door Peter Hegman – 1.0.1
    MetaSlider: door Team Updraft – 3.9.1
    Relevanssi: door Mikko Saari – 3.6.1
    Responsive Lightbox: door dFactory – 1.7.2
    Site Offline or Coming Soon: door wpecommerce – 1.6.6
    Sucuri Security - Auditing, Malware Scanner and Hardening: door Sucuri Inc. – 1.8.18
    WooCommerce - Store Exporter: door Visser Labs – 2.0.2
    WooCommerce PDF Invoices & Packing Slips: door Ewout Fernhout – 2.1.10
    WooCommerce Shortcodes: door WooThemes
    Claudio Sanches – 1.0.0 – Niet getest met de actieve versie van WooCommerce
    
    WooCommerce: door Automattic – 3.4.6
    
    ### Settings ###
    
    API Enabled: ?
    Force SSL: –
    Currency: EUR (€)
    Currency Position: left
    Thousand Separator: ,
    Decimal Separator: .
    Number of Decimals: 2
    Taxonomies: Product Types: external (external)
    grouped (grouped)
    simple (simple)
    variable (variable)
    
    Taxonomies: Product Visibility: exclude-from-catalog (exclude-from-catalog)
    exclude-from-search (exclude-from-search)
    featured (featured)
    outofstock (outofstock)
    rated-1 (rated-1)
    rated-2 (rated-2)
    rated-3 (rated-3)
    rated-4 (rated-4)
    rated-5 (rated-5)
    
    ### WC Pages ###
    
    Winkelbasis: #4 - /webshop/
    Winkelmand: #5 - /winkelmand/
    Afrekenen: #6 - /afrekenen/
    Mijn account: #7 - /mijn-account/
    Algemene voorwaarden: #177 - /webshop/algemene-voorwaarden/
    
    ### Theme ###
    
    Name: ms-dev Chocolaterie
    Version: 1.0
    Author URL: VE
    Child Theme: ? – Als je wijzigingen aanbrengt in WooCommerce of in een hoofdthema dat je niet zelf gebouwd hebt
    raden we het gebruik van een child thema aan. Zie: Hoe maak je een child thema
    
    WooCommerce Support: ?
    
    ### Templates ###
    
    Archive Template: Jouw thema heeft een woocommerce.php bestand. Je zal het woocommerce/archive-product.php template niet kunnen overschrijven omdat woocommerce.php prioriteit heeft over archive-product.php. Dit is bedoeld om weergave-problemen te voorkomen.
    Overrides: ms-dev/woocommerce/archive-product.php versie 2.0.0 is verouderd. De hoofdversie is 3.4.0
    ms-dev/woocommerce/cart/cart-shipping.php versie 2.3.0 is verouderd. De hoofdversie is 3.2.0
    ms-dev/woocommerce/cart/cart-totals.php
    ms-dev/woocommerce/cart/cart.php versie 2.3.8 is verouderd. De hoofdversie is 3.4.0
    ms-dev/woocommerce/checkout/form-billing.php versie 2.1.2 is verouderd. De hoofdversie is 3.0.9
    ms-dev/woocommerce/checkout/form-checkout.php
    ms-dev/woocommerce/checkout/form-shipping.php versie 2.2.0 is verouderd. De hoofdversie is 3.0.9
    ms-dev/woocommerce/checkout/payment.php versie 2.4.7 is verouderd. De hoofdversie is 3.4.0
    ms-dev/woocommerce/checkout/review-order.php versie 2.3.0 is verouderd. De hoofdversie is 3.3.0
    ms-dev/woocommerce/checkout/thankyou.php versie 2.2.0 is verouderd. De hoofdversie is 3.2.0
    ms-dev/woocommerce/content-product_cat.php versie 2.4.0 is verouderd. De hoofdversie is 2.6.1
    ms-dev/woocommerce/content-single-product.php versie 1.6.4 is verouderd. De hoofdversie is 3.4.0
    ms-dev/woocommerce/emails/admin-new-order.php versie 2.4.0 is verouderd. De hoofdversie is 2.5.0
    ms-dev/woocommerce/emails/customer-processing-order.php versie 2.4.0 is verouderd. De hoofdversie is 2.5.0
    ms-dev/woocommerce/emails/email-footer.php versie 2.0.0 is verouderd. De hoofdversie is 2.3.0
    ms-dev/woocommerce/emails/email-header.php
    ms-dev/woocommerce/emails/email-order-items.php versie 2.1.2 is verouderd. De hoofdversie is 3.4.0
    ms-dev/woocommerce/emails/email-styles.php versie 2.3.0 is verouderd. De hoofdversie is 3.3.0
    ms-dev/woocommerce/global/breadcrumb.php
    ms-dev/woocommerce/loop/add-to-cart.php versie 2.1.0 is verouderd. De hoofdversie is 3.3.0
    ms-dev/woocommerce/loop/loop-start.php versie 2.0.0 is verouderd. De hoofdversie is 3.3.0
    ms-dev/woocommerce/loop/price.php
    ms-dev/woocommerce/loop/rating.php versie 2.0.0 is verouderd. De hoofdversie is 3.0.0
    ms-dev/woocommerce/loop/sale-flash.php
    ms-dev/woocommerce/order/order-details-item.php versie 2.4.0 is verouderd. De hoofdversie is 3.0.0
    
    Outdated Templates: ?
    					
    					
    						Leer hoe te updaten
    
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support AW a11n

    (@slash1andy)

    Automattic Happiness Engineer

    Hey there!

    The first thing that springs to mind is using shipping zones, which was introduced with WooCommerce 2.6 (later on in the 2.x cycle). If you aren’t using zones, then all this would not work at all, since you are just trying to get methods with no zone.

    You’ll likely want to look at this page for more info on the functions : https://docs.woocommerce.com/wc-apidocs/class-WC_Shipping_Zone.html

    Hopefully that helps! Have a great one!

    Plugin Support Mike M. a11n

    (@mikedmoore)

    Automattic Happiness Engineer

    Hi there,

    We haven’t heard back from you in a while, so I’m going to mark this as resolved – if you have any further questions, you can start a new thread.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Shipping methods not loading or saving after update to wc3’ is closed to new replies.