我在电子商务网站上使用WordPress和WooCommerce插件最新版本 .
当我选择“本地取件”送货方式时,我想在WooCommerce“收到订单”页面中隐藏“送货地址” .
我怎样才能做到这一点?
以下是订单收到页面的屏幕截图:
提前致谢
是的,这可能是overriding WooCommerce templates(将WooCommerce插件模板文件夹复制到您的活动子主题或主题,将其重命名为woocommerce) .
您可以使用与the answer of your previous question相同的代码,但在其他模板中:order/order-details-customer.php 在Thankyou WooCommerce页面("Order receive"页面)上加载 .
使用以下代码替换 order/order-details-customer.php 模板上的代码 from line 64 to the end 部分:
<?php // BEGIN HERE $shipping_local_pickup = false; if ( $items_totals = $order->get_order_item_totals() ) { foreach ( $items_totals as $items_total ) { if ( $items_total['value'] == 'Local Pickup' && !$shipping_local_pickup ) $shipping_local_pickup = true; } } // END if ( ! wc_ship_to_billing_address_only() && $order->needs_shipping_address() && !$shipping_local_pickup ) : // HERE TOO ?> </div><!-- /.col-1 --> <div class="col-2"> <header class="title"> <h3><?php _e( 'Shipping Address', 'woocommerce' ); ?></h3> </header> <address> <?php echo ( $address = $order->get_formatted_shipping_address() ) ? $address : __( 'N/A', 'woocommerce' ); ?> </address> </div><!-- /.col-2 --> </div><!-- /.col2-set --> <?php endif; ?>
This is tested and fully functional code
参考文献:
Template Structure + Overriding Templates via a Theme
WooCommerce - Hide shipping address on local pickup in the email
1 回答
是的,这可能是overriding WooCommerce templates(将WooCommerce插件模板文件夹复制到您的活动子主题或主题,将其重命名为woocommerce) .
您可以使用与the answer of your previous question相同的代码,但在其他模板中:
order/order-details-customer.php 在Thankyou WooCommerce页面("Order receive"页面)上加载 .
使用以下代码替换 order/order-details-customer.php 模板上的代码 from line 64 to the end 部分:
This is tested and fully functional code
参考文献:
Template Structure + Overriding Templates via a Theme
WooCommerce - Hide shipping address on local pickup in the email