Banner Logo

Be a part of the family: Connect, Receive Support,
Contribute, and Reap Abundant Rewards!

Shipping by Zone – Seller’s shipping doesn’t display their shipping methods.

Theme and Plugin Support

Resolved
Viewing 2 reply threads
  • Author
    Posts
    • #141938
      l.gan
      Participant

      Hello

      Thanks for your amazing support.
      I ran into a problem when displaying the shipping method on the product page.
      I have some code – it works but outputs “seller’s shipping” as just a value, no internal deliveries.
      I mean, if there are 2 shipping methods in Seller’s Shipping:
      For example Courier – 20 euros and air delivery 50 euros.
      This code only outputs “Seller’s Shipping” – no attachments.

      Please tell me how to fix this code so that it works.
      In the attachment of the photo, how the code displays the methods of delivery now.
      I use the delivery method “Shipping by zones”

      <?php
      // get all zones
      $zones = WC_Shipping_Zones::get_zones();

      // get name of each zone and each shipping method for each zone
      foreach ( $zones as $zone_id => $zone ) {

      echo ‘<tr><td>’;

      echo ‘‘ . $zone[‘zone_name’] . ‘‘ . ‘</td><td>’;

      $zone_shipping_methods = $zone[‘shipping_methods’];

      foreach ( $zone_shipping_methods as $index => $method ) {
      $instance = $method->instance_settings;

      // Initialize
      $above = ”;
      $output_cost = __( ‘Free’, ‘woocommerce’ );

      // Cost isset
      if ( isset( $instance[‘cost’] ) ) {
      // NOT empty
      if ( ! empty ( $instance[‘cost’] ) ) {
      // Output
      $output_cost = wc_price( $instance[‘cost’] );
      }
      }

      // Min amount isset
      if ( isset( $instance[‘min_amount’] ) ) {
      // NOT empty
      if ( ! empty ( $instance[‘min_amount’] ) ) {
      // Above
      $above = __( ‘от ‘, ‘woocommerce’ );

      // Output
      $output_cost = wc_price( $instance[‘min_amount’] );
      }
      }

      echo $instance[‘title’] . ‘: ‘ . $above . ‘‘ . $output_cost . ‘‘ . ‘<br>’;
      }

      echo ‘</td></tr>’;
      }

      echo ‘</table></small></div>’;

      ?>

    • #141956

      Hi,
      kindly share the full code with the hook filter so we will check this on our end.

      Regards,

      • #141962
        l.gan
        Participant

        Yes, here
        Please have a look

        add_action( ‘woocommerce_after_add_to_cart_form’, ‘action_woocommerce_after_add_to_cart_form’, 10, 0 );

        function action_woocommerce_after_add_to_cart_form() {
        // get all zones
        $zones = WC_Shipping_Zones::get_zones();

        // get the shop base country
        $base_country = WC()->countries->get_base_country();
        $base_city = WC()->countries->get_base_city();

        // start display of table
        echo ‘<div>’ . __( ‘shipping’, ‘woocommerce’ );
        echo ‘<br><small><span class=”shipping-time-cutoff”>All orders are shipped from the ‘.$base_country.’. Order before 12AM Mon-Fri for same day delivery within ‘.$base_city.’. Order before 3PM Mon-Thu for next day delivery.</span></small>’;
        echo ‘<small><table class=”shipping-and-delivery-table”>’;

        // get name of each zone and each shipping method for each zone
        foreach ( $zones as $zone_id => $zone ) {

        echo ‘<tr><td>’;

        echo ‘‘ . $zone[‘zone_name’] . ‘‘ . ‘</td><td>’;

        $zone_shipping_methods = $zone[‘shipping_methods’];

        foreach ( $zone_shipping_methods as $index => $method ) {
        $instance = $method->instance_settings;

        // Initialize
        $above = ”;
        $output_cost = __( ‘Free’, ‘woocommerce’ );

        // Cost isset
        if ( isset( $instance[‘cost’] ) ) {
        // NOT empty
        if ( ! empty ( $instance[‘cost’] ) ) {
        // Output
        $output_cost = wc_price( $instance[‘cost’] );
        }
        }

        // Min amount isset
        if ( isset( $instance[‘min_amount’] ) ) {
        // NOT empty
        if ( ! empty ( $instance[‘min_amount’] ) ) {
        // Above
        $above = __( ‘от ‘, ‘woocommerce’ );

        // Output
        $output_cost = wc_price( $instance[‘min_amount’] );
        }
        }

        echo $instance[‘title’] . ‘: ‘ . $above . ‘‘ . $output_cost . ‘‘ . ‘<br>’;
        }

        echo ‘</td></tr>’;
        }

        echo ‘</table></small></div>’;
        }

      • #141977
        l.gan
        Participant
        This reply has been marked as private.
    • #141981

      HI,
      To show the vendor shipping you have to add custom code. vendor shipping is not included in the WC_Shipping_Zones::get_zones(); function.

      Kindly checkout the below page how wcmp show the shipping zones.
      https://github.com/multivendorx/dc-woocommerce-multi-vendor/blob/master/templates/vendor-dashboard/vendor-shipping.php

      Regards,

Viewing 2 reply threads

The topic ‘Shipping by Zone – Seller’s shipping doesn’t display their shipping methods.’ is closed to new replies.