【问题标题】:How do I set up ubercart to be conditional based on a ups shipping quote?如何根据 ups 运输报价将 ubercart 设置为有条件的?
【发布时间】:2012-10-06 20:43:34
【问题描述】:

我正在使用 Drupal 7 和 ubercart shipping。我的客户希望运输成本是地面报价,除非它 >= 50 美元。然后他想收取 50 美元的固定费用。

我创建了一个 50 美元的统一费率和一个 ups ground 报价。

我没有看到使用运输报价来确定运输方式的条件。有什么想法吗?

【问题讨论】:

    标签: drupal ubercart ups drupal-rules


    【解决方案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 ground。您可以修改它以自动选择 ups/fedex 之间最便宜的方法或类似的方法。

    无论如何。希望这对其他人有帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-06-09
      • 1970-01-01
      • 2013-09-16
      • 2023-04-08
      • 1970-01-01
      • 2017-05-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多