根据运送选项woo-commerce更改结帐表格

时间:2020-02-04 14:01:04

标签: wordpress forms woocommerce plugins checkout

如何更改不同运输方式的woo-Commerce结帐表格?如果他们选择免费送货,则结帐页面将显示送货表格。如果他们选择电子凭证,则结帐页面将显示一个更简单的表格。

2 个答案:

答案 0 :(得分:0)

在选择“电子凭证”送货方式时,您可以使用以下代码段隐藏所选的任何字段。只需将以下内容放入您的函数文件中即可。

<?php
  add_filter('woocommerce_checkout_fields', 'evoucher_remove_fields');

  function evoucher_remove_fields($fields) {

      $shipping_method ='evoucher:1'; // Change this to the value name of your shipping method
      global $woocommerce;
      $chosen_methods = WC()->session->get( 'chosen_shipping_methods' );
      $chosen_shipping = $chosen_methods[0];

      if ($chosen_shipping == $shipping_method) {
          unset($fields['billing']['billing_address_1']); // Hides billing address line 1
          unset($fields['billing']['billing_address_2']); // Hides billing address line 2
      }
      return $fields;

  }
?>

Source

答案 1 :(得分:0)

有一个不错的plugin用于此类目的。它的免费版本包括条件逻辑,例如更改表格,并选择“基于运送方式”。