2012-10-16 31 views
0

我正在使用Drupal 7與ubercart運輸。我的客戶希望運費成本高於地面報價,除非它大於等於50美元。然後,他想收取50美元的平價。如何根據ups運輸報價設置ubercart作爲條件?

我創建了一個價格爲50美元的統一費率和一個ups語錄報價。

我沒有看到使用航運報價確定運輸方式的情況。有任何想法嗎?

回答

1

得出這個想法。不漂亮,但它的作品。只要去ups選項,並添加一個條件與PHP評估。請注意,您必須有兩種付款方式才能使條件生效。粘貼這段代碼。

$method = array (
    'id' => 'ups', 
    'module' => 'uc_ups', 
    'title' => 'UPS', 
    'operations' => array (
    'configure' => array (
     'title' => 'configure', 
     'href' => 'admin/store/settings/quotes/settings/ups', 
    ), 
), 
    'quote' => array (
    'type' => 'small_package', 
    'callback' => 'uc_ups_quote', 
    'accessorials' => array (
     '03' => 'UPS Ground', 
    ), 
), 
    'ship' => array (
    'type' => 'small_package', 
    'callback' => 'uc_ups_fulfill_order', 
    'file' => 'uc_ups.ship.inc', 
    'pkg_types' => array (
     '02' => 'Customer Supplied Package', 
     '01' => 'UPS Letter', 
     '03' => 'Tube', 
     '04' => 'PAK', 
     21 => 'UPS Express Box', 
     24 => 'UPS 25KG Box', 
     25 => 'UPS 10KG Box', 
     30 => 'Pallet', 
     '2a' => 'Small Express Box', 
     '2b' => 'Medium Express Box', 
     '2c' => 'Large Express Box', 
    ), 
), 
    'cancel' => 'uc_ups_void_shipment', 
    'enabled' => 1, 
    'weight' => '0', 
); 

$details->postal_code = $order->delivery_postal_code; 
$details->zone = $order->delivery_zone; 
$details->country = $order->delivery_country; 

$quote = uc_ups_quote($order->products, $details , $method); 
return ($quote['03']['rate'] < 50); 

該方法可以針對其他類型的運輸進行調整,該條件僅適用於起飛場地。你可以修改它來自動選擇ups/fedex之間最便宜的方法或類似的東西。

無論如何。希望這可以幫助別人。