gpt4 book ai didi

woocommerce - 如何在 WooCommerce 中按付款方式对订单进行排序?

转载 作者:行者123 更新时间:2023-12-02 14:47:54 25 4
gpt4 key购买 nike

我只想查看那些通过 BACS/PayPal 购买的订单?我可以通过 WooCommerce >> 订单在管理员中按支付模式对订单进行排序吗?

最佳答案

在您的事件主题的 functions.php 中添加以下代码片段 -

/**
* Add payment method bulk filter for orders
*/
function add_filter_by_payment_method_orders() {
global $typenow;
if ( 'shop_order' === $typenow ) {
// get all payment methods
$gateways = WC()->payment_gateways->payment_gateways();
?>
<select name="_shop_order_payment_method" id="dropdown_shop_order_payment_method">
<option value=""><?php esc_html_e( 'All Payment Methods', 'text-domain' ); ?></option>
<?php foreach ( $gateways as $id => $gateway ) : ?>
<option value="<?php echo esc_attr( $id ); ?>" <?php echo esc_attr( isset( $_GET['_shop_order_payment_method'] ) ? selected( $id, $_GET['_shop_order_payment_method'], false ) : '' ); ?>>
<?php echo esc_html( $gateway->get_method_title() ); ?>
</option>
<?php endforeach; ?>
</select>
<?php
}
}
add_action( 'restrict_manage_posts', 'add_filter_by_payment_method_orders', 99 );

/**
* Process bulk filter order for payment method
*
*/
function add_filter_by_payment_method_orders_query( $vars ) {
global $typenow;
if ( 'shop_order' === $typenow && isset( $_GET['_shop_order_payment_method'] ) ) {
$vars['meta_key'] = '_payment_method';
$vars['meta_value'] = wc_clean( $_GET['_shop_order_payment_method'] );
}
return $vars;
}
add_filter( 'request', 'add_filter_by_payment_method_orders_query', 99 );

关于woocommerce - 如何在 WooCommerce 中按付款方式对订单进行排序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57806698/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com