Extending WooCommerce shipping logic to support variation-based local delivery

Issue background

A WooCommerce-powered online store was using a custom shipping logic developed to handle “Local Delivery” options through a function tied to shipping classes containing the word “Local.” This setup worked well for parent products but failed to apply correctly to individual product variations—a critical issue since certain product sizes required local-only delivery while others were available for nationwide shipping.

For example, a plant product might have multiple pot sizes:

  • 3-gallon: available for nationwide shipping
  • 7-gallon: too large to ship, local delivery only

The original logic only evaluated the parent product’s shipping class, ignoring variation-level overrides. As a result, “local delivery” logic wasn’t triggered when users selected a variation that required it.


Diagnosis

The development team reviewed the theme’s custom function zen_footer() and found that conditional logic for detecting shipping classes containing “local” had been commented out in prior iterations. The function relied instead on zen_get_local_shipping_pickup_zip_codes(), which didn’t account for variation-specific shipping settings.

Testing confirmed that:

  • Variation-level shipping classes were being ignored.
  • The green ZIP code availability button only updated after user interaction, not on initial page load.
  • Express payment buttons (Apple Pay, Google Pay) disappeared when variations were changed, due to JavaScript conflicts in the theme.

These behaviors caused inconsistent messaging such as “Not available in your area” even for eligible ZIP codes or failure to display local installation availability for specific variations.


Resolution steps

  1. Reinstated local delivery detection logic:
    Re-enabled the conditional check within zen_footer() for any shipping class name containing “local.” Extended the logic to apply not only to parent products but also to variation-level shipping classes.
  2. Synchronized variation behavior:
    Updated event triggers to ensure the green ZIP code message updates automatically on page load, not just after interaction. Fixed a bug where the message did not reflect the correct availability when a user’s ZIP code was saved in session.
  3. Improved service and materials messaging:
    Added category-specific logic:
    • Services (e.g., lawn-care-services, irrigation) now display messages like “This service is available for ZIP code: 12804.”
    • Materials (materials category) show “This material is available for delivery to: 12804.”

    Hid unnecessary “No installation available” notices for service and material products, ensuring a cleaner UX.

  4. Address bar and secondary prompt cleanup:
    Removed redundant secondary ZIP entry prompts in product summaries. Linked header ZIP input, product popups, and checkout ZIP validation so users only need to enter their ZIP once.
  5. Resolved express payment disappearance issue:
    Identified the cause in the theme’s WooCommerce Checkout Add-on plugin. Applied a patch to prevent Apple Pay and Google Pay buttons from vanishing after variation selection. Enabled AJAX add-to-cart functionality to avoid page reloads and improve overall speed.
  6. Final enhancements:
    Reindexed product data in Algolia to prevent outdated URLs and ensure search compatibility. Disabled dropdown functionality for products with only one available variation, preventing unnecessary page reloads.

Final outcome

The refined shipping logic now accurately supports both parent and variation-level configurations. Local delivery detection applies consistently, messages display correctly on load, and checkout experiences are smoother.

Key improvements achieved:

  • Fully functional local delivery logic for variable products.
  • Accurate availability messaging based on ZIP code and variation.
  • Streamlined user experience with reduced input redundancy.
  • Restored express checkout compatibility for mobile and desktop users.

This project highlights Freshy’s ability to enhance complex WooCommerce conditional logic—bridging the gap between user experience and backend flexibility while ensuring performance and compatibility across multiple plugins.


Looking to improve your WooCommerce shipping or checkout experience?
Freshy can help you develop custom shipping logic, dynamic ZIP code validation, and local delivery systems tailored to your products.
👉 Contact Freshy to discuss your project.