每件商品运费+ usps

时间:2018-08-03 22:55:37

标签: wordpress woocommerce

我正在尝试创建我认为在woo Commerce中相当普遍的设置。我已经看到几种尝试解决问题的“几乎”解决方案,但仍然遇到困难。

对于我的大多数产品,我使用USPS插件来计算商品的运输。我有一些大件物品,我刚刚将运费包括在该物品的费用中,以便可以“免费送货”的方式出售它们。

我已经在功能文件中添加了代码,以将购物车分为两批-“免费送货”物品和其余物品。

免费送货项目正常运行。但是第二部分提供了计算得出的费率免费送货选项。 Divided Cart

// Put inside packages
if ( $bulky_items ) {
    $packages[] = array(
        'ship_via'        => array( 'flat_rate' ),
        'contents'        => $bulky_items,
        'contents_cost'   => array_sum( wp_list_pluck( $bulky_items, 'line_total' ) ),
        'applied_coupons' => WC()->cart->applied_coupons,
        'destination'     => array(
            'country'   => WC()->customer->get_shipping_country(),
            'state'     => WC()->customer->get_shipping_state(),
            'postcode'  => WC()->customer->get_shipping_postcode(),
            'city'      => WC()->customer->get_shipping_city(),
            'address'   => WC()->customer->get_shipping_address(),
            'address_2' => WC()->customer->get_shipping_address_2()
        )
    );
}
if ( $regular_items ) {
    $packages[] = array(
        'contents'        => $regular_items,
        'contents_cost'   => array_sum( wp_list_pluck( $regular_items, 'line_total' ) ),
        'applied_coupons' => WC()->cart->applied_coupons,
        'destination'     => array(
            'country'   => WC()->customer->get_shipping_country(),
            'state'     => WC()->customer->get_shipping_state(),
            'postcode'  => WC()->customer->get_shipping_postcode(),
            'city'      => WC()->customer->get_shipping_city(),
            'address'   => WC()->customer->get_shipping_address(),
            'address_2' => WC()->customer->get_shipping_address_2()
        )
    );
}    

是因为我的第二个if语句没有ship_via行吗?我找不到适合于usps计算出的费率的子弹。

我怀疑我缺少明显的东西,但我被卡住了。

0 个答案:

没有答案
相关问题