Today, We want to share with you wc_order item.In this post we will show you wc_order_item_product, hear for woocommerce get order items we will give you demo and example for implement.In this post, we will learn about PHP woocommerce_payment_complete_order_status Examples with an example.
WC_Order, PHP Code Examples
here learn to WooCommerce: Get Order Info (total, items, etc) From $get_ord_data Object, get order details by order id in woocommerce.
Using some WC_Order and WC_Abstract_Order methods (example):
$get_ord_data = wc_get_order( $order_id ); $order_id = $get_ord_data->get_id(); $parent_id = $get_ord_data->get_parent_id(); $payment_title = $get_ord_data->get_payment_method_title(); $date_created = $get_ord_data->get_date_created(); $date_modified = $get_ord_data->get_date_modified(); $user_id = $get_ord_data->get_user_id(); $user = $get_ord_data->get_user(); $order_status = $get_ord_data->get_status(); $currency = $get_ord_data->get_currency(); $payment_method = $get_ord_data->get_payment_method(); $billing_country = $get_ord_data->get_billing_country();
access to $get_ord_data variable (Get Order ID and Key)
$get_ord_data->get_id(); $get_ord_data->get_order_key();
Get Order Totals $0.00
$get_ord_data->get_formatted_order_total(); $get_ord_data->get_cart_tax(); $get_ord_data->get_currency(); $get_ord_data->get_discount_tax(); $get_ord_data->get_discount_to_display(); $get_ord_data->get_discount_total(); $get_ord_data->get_fees(); $get_ord_data->get_formatted_line_subtotal(); $get_ord_data->get_shipping_tax(); $get_ord_data->get_shipping_total(); $get_ord_data->get_subtotal(); $get_ord_data->get_subtotal_to_display(); $get_ord_data->get_tax_location(); $get_ord_data->get_tax_totals(); $get_ord_data->get_taxes(); $get_ord_data->get_total(); $get_ord_data->get_total_discount(); $get_ord_data->get_total_tax(); $get_ord_data->get_total_refunded(); $get_ord_data->get_total_tax_refunded(); $get_ord_data->get_total_shipping_refunded(); $get_ord_data->get_item_count_refunded(); $get_ord_data->get_total_qty_refunded(); $get_ord_data->get_qty_refunded_for_item(); $get_ord_data->get_total_refunded_for_item(); $get_ord_data->get_tax_refunded_for_item(); $get_ord_data->get_total_tax_refunded_by_rate_id(); $get_ord_data->get_remaining_refund_amount();
Get Order Status
$get_ord_data->get_status();
Get Order URLs
$get_ord_data->get_checkout_payment_url(); $get_ord_data->get_checkout_order_received_url(); $get_ord_data->get_cancel_order_url(); $get_ord_data->get_cancel_order_url_raw(); $get_ord_data->get_cancel_endpoint(); $get_ord_data->get_view_order_url(); $get_ord_data->get_edit_order_url();
Get Order Payment Details
$get_ord_data->get_payment_method(); $get_ord_data->get_payment_method_title(); $get_ord_data->get_transaction_id();
Get Order User, Billing & Shipping Addresses
$get_ord_data->get_customer_id(); $get_ord_data->get_user_id(); $get_ord_data->get_user(); $get_ord_data->get_customer_ip_address(); $get_ord_data->get_customer_user_agent(); $get_ord_data->get_created_via(); $get_ord_data->get_customer_note(); $get_ord_data->get_address_prop(); $get_ord_data->get_billing_first_name(); $get_ord_data->get_billing_last_name(); $get_ord_data->get_billing_company(); $get_ord_data->get_billing_address_1(); $get_ord_data->get_billing_address_2(); $get_ord_data->get_billing_city(); $get_ord_data->get_billing_state(); $get_ord_data->get_billing_postcode(); $get_ord_data->get_billing_country(); $get_ord_data->get_billing_email(); $get_ord_data->get_billing_phone(); $get_ord_data->get_shipping_first_name(); $get_ord_data->get_shipping_last_name(); $get_ord_data->get_shipping_company(); $get_ord_data->get_shipping_address_1(); $get_ord_data->get_shipping_address_2(); $get_ord_data->get_shipping_city(); $get_ord_data->get_shipping_state(); $get_ord_data->get_shipping_postcode(); $get_ord_data->get_shipping_country(); $get_ord_data->get_address(); $get_ord_data->get_shipping_address_map_url(); $get_ord_data->get_formatted_billing_full_name(); $get_ord_data->get_formatted_shipping_full_name(); $get_ord_data->get_formatted_billing_address(); $get_ord_data->get_formatted_shipping_address();
Get Order Dates
$get_ord_data->get_date_created(); $get_ord_data->get_date_modified(); $get_ord_data->get_date_completed(); $get_ord_data->get_date_paid();
Get Order Shipping
$get_ord_data->get_shipping_method(); $get_ord_data->get_shipping_methods(); $get_ord_data->get_shipping_to_display();
Get Order Lines
$get_ord_data->get_line_subtotal(); $get_ord_data->get_line_tax(); $get_ord_data->get_line_total();
Other Secondary Items Stuff
$get_ord_data->get_items_key(); $get_ord_data->get_items_tax_classes(); $get_ord_data->get_item_count(); $get_ord_data->get_item_total(); $get_ord_data->get_downloadable_items();
Get and Loop Over Order Items
foreach ( $get_ord_data->get_items() as $item_id => $item ) { $product_id = $item->get_product_id(); $variation_id = $item->get_variation_id(); $product = $item->get_product(); $name = $item->get_name(); $quantity = $item->get_quantity(); $subtotal = $item->get_subtotal(); $total = $item->get_total(); $tax = $item->get_subtotal_tax(); $taxclass = $item->get_tax_class(); $taxstat = $item->get_tax_status(); $allmeta = $item->get_meta_data(); $somemeta = $item->get_meta( '_whatever', true ); $type = $item->get_type(); }
access to $order_id variable
here Get $get_ord_data object from order ID
$get_ord_data = wc_get_order( $order_id ); if ( $get_ord_data ) { $get_ord_data->get_formatted_order_total( ); // etc. // etc. }
access to $email variable
using Get $get_ord_data object from $email
$get_ord_data = $email->object; if ( $get_ord_data ) { $get_ord_data->get_id(); $get_ord_data->get_formatted_order_total( ); // etc. // etc. }
I hope you get an idea about wc_order.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.