├── README.md ├── admin ├── controller │ └── shipping │ │ └── my.php ├── language │ └── zh-CN │ │ └── shipping │ │ └── my.php └── view │ └── template │ └── shipping │ └── my.tpl └── catalog ├── language └── zh-CN │ └── shipping │ └── my.php └── model └── shipping └── my.php /README.md: -------------------------------------------------------------------------------- 1 | opencart-shipping-plugin 2 | ======================== 3 | 4 | opencart 自定义灵活配送插件 5 | 具体介绍:http://www.yuansir-web.com/?p=509 6 | -------------------------------------------------------------------------------- /admin/controller/shipping/my.php: -------------------------------------------------------------------------------- 1 | load->language('shipping/my'); 14 | 15 | $this->document->setTitle($this->language->get('heading_title')); 16 | 17 | $this->load->model('setting/setting'); 18 | 19 | if (($this->request->server['REQUEST_METHOD'] == 'POST')) { 20 | 21 | $this->model_setting_setting->editSetting('my', $this->request->post); 22 | 23 | $this->session->data['success'] = $this->language->get('text_success'); 24 | 25 | $this->redirect($this->url->link('extension/shipping', 'token=' . $this->session->data['token'], 'SSL')); 26 | } 27 | 28 | $this->data['heading_title'] = $this->language->get('heading_title'); 29 | 30 | 31 | $this->data['button_save'] = $this->language->get('button_save'); 32 | $this->data['button_cancel'] = $this->language->get('button_cancel'); 33 | 34 | $this->data['tab_general'] = $this->language->get('tab_general'); 35 | 36 | $this->data['heading_title'] = $this->language->get('heading_title'); 37 | 38 | if (isset($this->error['warning'])) { 39 | $this->data['error_warning'] = $this->error['warning']; 40 | } else { 41 | $this->data['error_warning'] = ''; 42 | } 43 | 44 | $this->data['breadcrumbs'] = array(); 45 | 46 | $this->data['breadcrumbs'][] = array( 47 | 'text' => $this->language->get('text_home'), 48 | 'href' => $this->url->link('common/home', 'token=' . $this->session->data['token'], 'SSL'), 49 | 'separator' => false 50 | ); 51 | 52 | $this->data['breadcrumbs'][] = array( 53 | 'text' => $this->language->get('text_shipping'), 54 | 'href' => $this->url->link('extension/shipping', 'token=' . $this->session->data['token'], 'SSL'), 55 | 'separator' => ' :: ' 56 | ); 57 | 58 | $this->data['breadcrumbs'][] = array( 59 | 'text' => $this->language->get('heading_title'), 60 | 'href' => $this->url->link('shipping/my', 'token=' . $this->session->data['token'], 'SSL'), 61 | 'separator' => ' :: ' 62 | ); 63 | 64 | $this->data['action'] = $this->url->link('shipping/my', 'token=' . $this->session->data['token'], 'SSL'); 65 | 66 | $this->data['cancel'] = $this->url->link('extension/shipping', 'token=' . $this->session->data['token'], 'SSL'); 67 | 68 | if (isset($this->request->post['my_common'])) { 69 | $this->data['my_common'] = $this->request->post['my_common']; 70 | } else { 71 | $this->data['my_common'] = $this->config->get('my_common'); 72 | } 73 | 74 | if (isset($this->request->post['my_free'])) { 75 | $this->data['my_free'] = $this->request->post['my_free']; 76 | } else { 77 | $this->data['my_free'] = $this->config->get('my_free'); 78 | } 79 | 80 | if (isset($this->request->post['my_single_add'])) { 81 | $this->data['my_single_add'] = $this->request->post['my_single_add']; 82 | } else { 83 | $this->data['my_single_add'] = $this->config->get('my_single_add'); 84 | } 85 | 86 | if (isset($this->request->post['my_special_id'])) { 87 | $this->data['my_special_id'] = $this->request->post['my_special_id']; 88 | } else { 89 | $this->data['my_special_id'] = $this->config->get('my_special_id'); 90 | } 91 | 92 | if (isset($this->request->post['my_special_single_price'])) { 93 | $this->data['my_special_single_price'] = $this->request->post['my_special_single_price']; 94 | } else { 95 | $this->data['my_special_single_price'] = $this->config->get('my_special_single_price'); 96 | } 97 | 98 | if (isset($this->request->post['my_special_zone_price'])) { 99 | $this->data['my_special_zone_price'] = $this->request->post['my_special_zone_price']; 100 | } else { 101 | $this->data['my_special_zone_price'] = $this->config->get('my_special_zone_price'); 102 | } 103 | 104 | if (isset($this->request->post['my_special_geo_zone_id'])) { 105 | $this->data['my_special_geo_zone_id'] = $this->request->post['my_special_geo_zone_id']; 106 | } else { 107 | $this->data['my_special_geo_zone_id'] = $this->config->get('my_special_geo_zone_id'); 108 | } 109 | 110 | if (isset($this->request->post['my_geo_zone_id'])) { 111 | $this->data['my_geo_zone_id'] = $this->request->post['my_geo_zone_id']; 112 | } else { 113 | $this->data['my_geo_zone_id'] = $this->config->get('my_geo_zone_id'); 114 | } 115 | 116 | if (isset($this->request->post['my_status'])) { 117 | $this->data['my_status'] = $this->request->post['my_status']; 118 | } else { 119 | $this->data['my_status'] = $this->config->get('my_status'); 120 | } 121 | 122 | if (isset($this->request->post['my_sort_order'])) { 123 | $this->data['my_sort_order'] = $this->request->post['my_sort_order']; 124 | } else { 125 | $this->data['my_sort_order'] = $this->config->get('my_sort_order'); 126 | } 127 | 128 | 129 | 130 | $this->load->model('localisation/geo_zone'); 131 | $this->data['geo_zones'] = $this->model_localisation_geo_zone->getGeoZones(); 132 | 133 | $this->template = 'shipping/my.tpl'; 134 | 135 | $this->children = array( 136 | 'common/header', 137 | 'common/footer', 138 | ); 139 | 140 | $this->response->setOutput($this->render()); 141 | } 142 | 143 | } 144 | -------------------------------------------------------------------------------- /admin/language/zh-CN/shipping/my.php: -------------------------------------------------------------------------------- 1 | 2 |
3 | 8 | 9 |
10 | 11 |
12 |
13 |

14 |
15 |
16 |
17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 70 | 71 | 72 | 73 | 83 | 84 | 85 | 86 | 87 | 88 | 89 |
通用运费:
正常商品购买一件的运费
全免:
全免运费的购买额度,超过此额度则运费全免
单件增加价格:
每多买一件增加的物流费,例如:+500
特殊品类ID:
填入特殊商品类别ID,多个用英文半角逗号隔开
特殊品类额外运费:
特殊商品类别运费相对于通用运费额外增加的运费例如:+500或者-500
特殊地区:
选择适用于特的地区
52 |
特殊地区单件增加运费:
特殊地区单件相对于通用运费额外增加的运费,例如:+500或-500
适用地区
状态(Status): 82 |
排序(Sort Order):
90 |
91 |
92 |
93 |
94 | -------------------------------------------------------------------------------- /catalog/language/zh-CN/shipping/my.php: -------------------------------------------------------------------------------- 1 | load->language('shipping/my'); 11 | 12 | $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "zone_to_geo_zone WHERE geo_zone_id='" . (int) $this->config->get('my_geo_zone_id') . "' AND country_id='" . (int) $address['country_id'] . "' AND (zone_id = '" . (int) $address['zone_id'] . "' OR zone_id = '0')"); 13 | 14 | if (!$this->config->get('citylink_geo_zone_id')) { 15 | $status = true; 16 | } elseif ($query->num_rows) { 17 | $status = true; 18 | } else { 19 | $status = false; 20 | } 21 | 22 | $method_data = $quote_data = $cart = $cart_products = $special_zone_ids = array(); 23 | 24 | $in_pecial_zone = FALSE; 25 | //特殊区域的ID 26 | $special_zone_ids = $this->db->query("SELECT zone_id FROM " . DB_PREFIX . "zone_to_geo_zone WHERE geo_zone_id = " . $this->config->get('my_special_geo_zone_id')); 27 | 28 | foreach ($special_zone_ids->rows as $key) { 29 | if ((int) $address['zone_id'] == (int) $key['zone_id']) { 30 | $in_pecial_zone = TRUE; 31 | break; 32 | } 33 | } 34 | 35 | $data = $special_catetory_products = $special_category = $cart_products = $temp_array = array(); 36 | $special_category_pro_count = $filter_category_id = 0; 37 | 38 | //获取购物车中商品的ID 39 | $cart_products = $this->cart->getProducts(); 40 | foreach ($cart_products as $key => $value) { 41 | $temp_array[$value['product_id']] = $value['product_id']; 42 | } 43 | $cart_products = array_keys($temp_array); 44 | 45 | if ($this->config->get('my_special_id')) { 46 | 47 | $special_category = explode(',', $this->config->get('my_special_id')); 48 | 49 | $this->load->model('catalog/product'); 50 | 51 | foreach ($special_category as $filter_category_id) { 52 | $data['filter_category_id'] = $filter_category_id; 53 | //获取购物车中特殊类别商品的数量 54 | $special_catetory_products = array_keys($this->model_catalog_product->getProducts($data)); 55 | 56 | if (count(array_intersect($cart_products, $special_catetory_products))) { 57 | $special_category_pro_count = 1; 58 | break; 59 | } 60 | } 61 | } 62 | 63 | $this->load->model('total/total'); 64 | $cost = 0; 65 | //正常购买商品的运费 = 通用单个商品运费价格+额外数量增加的价格*(购买商品数量-1) 66 | $cost = $this->config->get('my_common') + $this->config->get('my_single_add') * ($this->cart->countProducts() - 1); 67 | 68 | if ($in_pecial_zone == TRUE) { 69 | //如果在运输地点在特殊区域内 70 | //总运费 = 正常购买商品的运费+特殊区域额外运费 71 | $cost += (int) $this->config->get('my_special_zone_price'); 72 | } 73 | 74 | if ($special_category_pro_count > 0) { 75 | //如果购买的商品中有特殊列别下的商品 76 | //总运费 = 总运费+特殊类别商品额外金额 77 | $cost += (int) $this->config->get('my_special_single_price'); 78 | } 79 | 80 | if ($this->cart->getSubTotal() >= $this->config->get('my_free')) { 81 | //如果总价大于等于免运费额度,则免费 82 | $cost = 0; 83 | } 84 | 85 | if ($status) { 86 | $quote_data['my'] = array( 87 | 'code' => 'my.my', 88 | 'title' => $this->language->get('text_description'), 89 | 'cost' => $cost, 90 | 'tax_class_id' => 0, 91 | 'text' => $this->currency->format($cost) 92 | ); 93 | } 94 | 95 | $method_data = array( 96 | 'code' => 'my', 97 | 'title' => $this->language->get('text_title'), 98 | 'quote' => $quote_data, 99 | 'sort_order' => $this->config->get('my_sort_order'), 100 | 'error' => false 101 | ); 102 | 103 | return $method_data; 104 | } 105 | 106 | } 107 | --------------------------------------------------------------------------------