更新到Woocommerce 3.0时,在模板的代码中进行自定义;order.php“;
很高兴你能帮助我 在Woocommerce 2.6版本中,编辑模板“order.php”以使其适应自定义代码。我把它放在我的wordpress模板中 您编辑的模板“woocommerce/templates/myaccount/order.php” 升级到新版本的“Woocommerce 3.0.9”后。代码对我不起作用 有关守则是:更新到Woocommerce 3.0时,在模板的代码中进行自定义;order.php“;,woocommerce,Woocommerce,很高兴你能帮助我 在Woocommerce 2.6版本中,编辑模板“order.php”以使其适应自定义代码。我把它放在我的wordpress模板中 您编辑的模板“woocommerce/templates/myaccount/order.php” 升级到新版本的“Woocommerce 3.0.9”后。代码对我不起作用 有关守则是: $customer_orders = get_posts( apply_filters( 'woocommerce_my_account_my_orders_qu
$customer_orders = get_posts( apply_filters( 'woocommerce_my_account_my_orders_query', array(
'numberposts' => $order_count,
'meta_key' => '_customer_user',
'meta_value' => get_current_user_id(),
'post_type' => 'shop_order',
'post_status' => 'publish'
) ) );
if ( $customer_orders ) : ?>
<table class="shop_table my_account_orders table-striped" width="100%">
<thead>
<tr>
<th class="order-number"><span class="nobr"><?php _e( 'Order', 'woocommerce' ); ?></span></th>
<th class="order-date"><span class="nobr"><?php _e( 'Date', 'woocommerce' ); ?></span></th>
<th class="order-status"><span class="nobr"><?php _e( 'Status', 'woocommerce' ); ?></span></th>
<th class="order-total"><span class="nobr"><?php _e( 'Total', 'woocommerce' ); ?></span></th>
<th class="order-actions"> </th>
</tr>
</thead>
<tbody><?php
foreach ( $customer_orders as $customer_order ) {
$order = new WC_Order();
$order->populate( $customer_order );
$status = get_term_by( 'slug', $order->status, 'shop_order_status' );
$item_count = $order->get_item_count();
?><tr class="order">
<td class="order-number">
<a href="<?php echo $order->get_view_order_url(); ?>">
<?php echo $order->get_order_number(); ?>
</a>
</td>
<td class="order-date">
<time datetime="<?php echo date( 'Y-m-d', strtotime( $order->order_date ) ); ?>" title="<?php echo esc_attr( strtotime( $order->order_date ) ); ?>"><?php echo date_i18n( get_option( 'date_format' ), strtotime( $order->order_date ) ); ?></time>
</td>
<td class="order-status" style="text-align:left; white-space:nowrap;">
<?php echo wc_get_order_status_name( $order->get_status() ); ?>
</td>
<td class="order-total">
<?php echo sprintf( _n( '%s for %s item', '%s for %s items', $item_count, 'woocommerce' ), $order->get_formatted_order_total(), $item_count ); ?>
</td>
<td class="order-actions">
<?php
$actions = array();
if ( in_array( $order->status, apply_filters( 'woocommerce_valid_order_statuses_for_payment', array( 'pending', 'failed' ), $order ) ) ) {
$actions['pay'] = array(
'url' => $order->get_checkout_payment_url(),
'name' => __( 'Pay', 'woocommerce' )
);
}
if ( in_array( $order->status, apply_filters( 'woocommerce_valid_order_statuses_for_cancel', array( 'pending', 'failed' ), $order ) ) ) {
$actions['cancel'] = array(
'url' => $order->get_cancel_order_url( get_permalink( wc_get_page_id( 'myaccount' ) ) ),
'name' => __( 'Cancel', 'woocommerce' )
);
}
$actions['view'] = array(
'url' => $order->get_view_order_url(),
'name' => __( 'View', 'woocommerce' )
);
$actions = apply_filters( 'woocommerce_my_account_my_orders_actions', $actions, $order );
if ($actions) {
foreach ( $actions as $key => $action ) {
echo '<a href="' . esc_url( $action['url'] ) . '" class="button ' . sanitize_html_class( $key ) . '">' . esc_html( $action['name'] ) . '</a>';
}
}
?>
</td>
</tr>
<?php
foreach( $order->get_items() as $item_id => $item ) {
$product = apply_filters( 'woocommerce_order_item_product', $order->get_product_from_item( $item ), $item );
wc_get_template( 'order/order-details-item.php', array(
'order' => $order,
'item_id' => $item_id,
'item' => $item,
'show_purchase_note' => $show_purchase_note,
'purchase_note' => $product ? get_post_meta( $product->id, '_purchase_note', true ) : '',
'product' => $product,
) );
}
?>
<?php do_action( 'woocommerce_order_items_table', $order ); ?>
<?php
}
?></tbody>
<tbody>
</tbody>
</table>
$customer\u orders=get\u posts(应用过滤器('woocommerce\u my\u account\u my\u orders\u query',数组(
'numberposts'=>$order\u count,
“元密钥”=>“\u客户\u用户”,
“元值”=>获取当前用户id(),
“post_type”=>“shop_order”,
“发布状态”=>“发布”
) ) );
如果($customer\u orders):?>
首先,你不应该编辑woocommerce插件代码。如果你真的需要修改代码,那么将模板文件复制到你的主题中并修改它
这样做的过程是什么