WooCommerce - 在感谢页面上选择本地取货时隐藏送货地址 [英] WooCommerce - Hide shipping address when local pickup is chosen on thankyou page
问题描述
我在电子商务网站上使用带有 WooCommerce 插件的 WordPress 最新版本.
I am using WordPress with WooCommerce plugin Last version on an e-commerce website.
我想在选择本地提货"运输方法时隐藏Woocommerce订单收到的订单"页面中的送货地址".
I would like to hide the "Shipping Address" in WooCommerce "Order received" page when "Local Pickup" shipping method is chosen.
我怎样才能做到这一点?
How can I achieve this?
这是收到订单页面的截图:
Here is the screenshot Of the Order Received page:
提前致谢
推荐答案
是的,这是可能的 overridingWooCommerce 模板 (将 WooCommerce 插件模板文件夹复制到您的活动子主题或主题,将其重命名为 woocommerce).
Yes it's possible overriding WooCommerce templates (copying the WooCommerce plugin templates folder to your active child theme or theme, renaming it woocommerce).
您可以使用与 您上一个问题的答案,但在另一个模板中:order/order-details-customer.php
加载到Thankyou WooCommerce 页面(订单接收"页面).
You can use the same code as the answer of your previous question, but in an other template:
order/order-details-customer.php
that is loaded on Thankyou WooCommerce page ("Order receive" page).
用此代码替换order/order-details-customer.php
模板上从第64行到末尾的代码部分:
Replace in the portion of code from line 64 to the end on order/order-details-customer.php
template with this code:
<?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; ?>
这是经过测试且功能齐全的代码
参考文献:
这篇关于WooCommerce - 在感谢页面上选择本地取货时隐藏送货地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!