2017-04-17 40 views
1

对我来说这是一个棘手的问题,我一直在四处寻找,我似乎无法找到答案,我希望你会。全球仅附带一组团队运费

我卖的照片,在下载模式,但canvasses /木材等。所有这些都不需要运输。我使用Global Add on插件将它们全部制作完成,因此它们被称为组。

现在我想添加打印件,并且对于此组,必须添加运费。

所以没有运输成本,但是当选择打印时,必须添加3欧元。 我该如何做到这一点?产品页面的

例子: http://www.worldofpixels.be/product/org3_11/

亲切的问候, 本

+0

检查该片段是否有助于you.https://www.xadapter.com/add-additional-cost-shipping-service-based-shipping-class/ –

+0

我会详细检查这一点,但如何修改Global Add Ons脚本? :/ – user1562864

+0

你可以推广脚本来增加一些额外的费用与邮寄班 –

回答

0

请尝试以下修改的摘录。

function add_extra_charge($rates, $item_id) { 
    global $woocommerce; 
    $extra_cost = 0; 
    foreach ($woocommerce->cart->cart_contents as $product) { 
     //$product is a array, and print-pack is the slug of the attribute name print 
     if ($product['variation_id'] && in_array('print-pack', $product['variation'])) { 

      $extra_cost = 3; 
      break; 
     } 
    } 

    foreach ($rates as $key => $value) { 
     $rates[$key]->cost += $extra_cost; 
    } 

    return $rates; 
} 

add_filter('woocommerce_package_rates', 'add_extra_charge', 100, 2); 
+0

我在functions.php中添加了这个,打印属性slug改变了,一切似乎都奏效了(请查看printscreen http://imgur.com/I3NTiRq)。但3€仍然没有作为航运增加:( – user1562864

+0

检查你的属性slu is是否正确?检查代码进入if条件 –