A
A
alexiusgrey2021-11-12 08:02:28
WordPress
alexiusgrey, 2021-11-12 08:02:28

Is there an analogue for displaying the components of an order by analogy with a product?

I need to display all user orders with my markup. On the left - the number and the image (it's not a problem to add an image), and on the right - the order date, status, quantity, price, and custom labels.
I just wanted to change the woocommerce/myaccount/orders.php template in my theme, but the problem is that everything is displayed there in a loop and linked to columns. That is, even if the table is rewritten into divs, then I cannot separately wrap the divs I need in a wrapper. This either applies to all items in the cycle, or the structure is broken.
I would like to demolish everything that is in this template, and display it in a new cycle, and display what I need in my html-css markup. As for example with product product->get_price, so order->get_date.
Maybe someone before me managed to make something worthwhile out of that terrible table? By hand, I mean.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
Artem Zolin, 2021-11-12
@artzolin

Receive the necessary orders with the help wc_get_orders()and loop the output of the markup that you need

$args = array(
  'author' => get_current_user_id();
);

$orders = wc_get_orders( $args );

foreach ( $orders as $key => $order ) {

  // данные заказа
  $data = $order->get_data();

  echo $data['id'];
  echo $data['parent_id'];
  echo $data['status'];
  echo $data['currency'];
  echo $data['version'];
  echo $data['payment_method'];
  echo $data['payment_method_title'];
  echo $data['payment_method'];
  echo $data['payment_method'];

  // еще данные
  echo $data['discount_total'];
  echo $data['discount_tax'];
  echo $data['shipping_total'];
  echo $data['shipping_tax'];
  echo $data['cart_tax'];
  echo $data['total_tax'];
  echo $data['customer_id']; 

  // ... и все в том же духе

}

W
wscms, 2015-02-25
@sugarufc

Before the foreach
$uri = '';

V
Vladimir Martyanov, 2015-02-25
@vilgeforce

You made a mistake many times: when you attached screenshots instead of formatted text. It is very convenient to count lines.
Once again - when they did not read the error message and immediately began to write "pamagiti!". For in the error it is clearly written on which line and what exactly is the problem.

F
FanatPHP, 2015-02-25
@FanatPHP

1. you are trying to access a non-existent variable.
2.http_build_query()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question