Пример #1
0
 /**
  * Looks through the cart to see if shipping is actually required.
  *
  * @return bool whether or not the cart needs shipping
  */
 public function needs_shipping()
 {
     // If shipping is disabled or not yet configured, we can skip this.
     if (!wc_shipping_enabled() || 0 === wc_get_shipping_method_count(true)) {
         return false;
     }
     $needs_shipping = false;
     if (!empty($this->cart_contents)) {
         foreach ($this->cart_contents as $cart_item_key => $values) {
             $_product = $values['data'];
             if ($_product->needs_shipping()) {
                 $needs_shipping = true;
             }
         }
     }
     return apply_filters('woocommerce_cart_needs_shipping', $needs_shipping);
 }
 /**
  * Show zones
  */
 protected function zones_screen()
 {
     global $wpdb;
     $allowed_countries = WC()->countries->get_allowed_countries();
     $continents = WC()->countries->get_continents();
     $method_count = wc_get_shipping_method_count();
     wp_localize_script('wc-shipping-zones', 'shippingZonesLocalizeScript', array('zones' => WC_Shipping_Zones::get_zones(), 'default_zone' => array('zone_id' => 0, 'zone_name' => '', 'zone_order' => null), 'wc_shipping_zones_nonce' => wp_create_nonce('wc_shipping_zones_nonce'), 'strings' => array('unload_confirmation_msg' => __('Your changed data will be lost if you leave this page without saving.', 'woocommerce'), 'save_failed' => __('Your changes were not saved. Please retry.', 'woocommerce'), 'no_shipping_methods_offered' => __('No shipping methods offered to this zone.', 'woocommerce'))));
     wp_enqueue_script('wc-shipping-zones');
     include_once dirname(__FILE__) . '/views/html-admin-page-shipping-zones.php';
 }
Пример #3
0
 /**
  * Test wc_get_shipping_method_count()
  *
  * @since 2.6.0
  */
 public function test_wc_get_shipping_method_count()
 {
     // Without legacy methods.
     $this->assertEquals(0, wc_get_shipping_method_count(false));
     // With legacy methods.
     $this->assertEquals(0, wc_get_shipping_method_count(true));
 }
 /**
  * No shipping methods.
  */
 public static function no_shipping_methods_notice()
 {
     if (wc_shipping_enabled() && (empty($_GET['page']) || empty($_GET['tab']) || 'wc-settings' !== $_GET['page'] || 'shipping' !== $_GET['tab'])) {
         global $wpdb;
         $product_count = wp_count_posts('product');
         $method_count = wc_get_shipping_method_count();
         if ($product_count->publish > 0 && 0 === $method_count) {
             include 'views/html-notice-no-shipping-methods.php';
         }
         if ($method_count > 0) {
             self::remove_notice('no_shipping_methods');
         }
     }
 }