douhuiqi3855 2019-04-18 09:36
浏览 28

如果在结账时选择了字段选项,如何加倍运费?

I've found already many helpful code snippets for my WooCommerce 3 online shop.

Description/Example

If a customer buys 10 items and only 7 items are available he can choose (via a select field) to partially ship the order. If the option "Ja, teilliefern" is selected, the freight charges should be charged twice.

  • At "regular shipping" 4,90 € -> 9,80 €
  • At "free shipping" 0,00 € -> 4,90 €

Below is my current code:

add_filter( 'woocommerce_checkout_fields' , 'wp_bibel_de_add_checkout_fields' );

function wp_bibel_de_add_checkout_fields( $fields ) {
     $fields['billing']['billing_phone'] = array(
        'label' => 'Telefonnummer',
        'placeholder' => 'Telefonnr.',
        'required' => true,
        'class' => array('form-row-wide'),
        'clear' => true
    );


     $fields['billing']['billing_delivery'] = array(
        'type' => 'select',
        'label' => 'Wünschen Sie eine Teillieferung der verfügbaren Artikel?',
        'placeholder' => 'bitte auswählen...',
        'required' => false,
        'class' => array('form-row-wide'),
        'clear' => true,
        'options' => array(
            ' ' => ' ',
            'ja' => 'Ja, teilliefern',
            'nein' => 'Nein'
        )


    );

     return $fields;
}

add_action( 'woocommerce_admin_order_data_after_shipping_address', 'wp_bibel_de_add_custom_order_data', 10, 1 );

function wp_bibel_de_add_custom_order_data( $order ) {
    echo get_post_meta( $order->id, '_billing_delivery', true );
}
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
    • ¥15 微信会员卡接入微信支付商户号收款
    • ¥15 如何获取烟草零售终端数据
    • ¥15 数学建模招标中位数问题
    • ¥15 phython路径名过长报错 不知道什么问题
    • ¥15 深度学习中模型转换该怎么实现
    • ¥15 HLs设计手写数字识别程序编译通不过
    • ¥15 Stata外部命令安装问题求帮助!
    • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
    • ¥15 TYPCE母转母,插入认方向