Home – Download › Forums › Plugin › WooCommerce Development Tips
- This topic has 0 replies, 1 voice, and was last updated 6 years, 6 months ago by
admin.
Viewing 0 reply threads
-
AuthorPosts
-
-
June 10, 2019 at 7:13 pm #175
admin
KeymasterHow to get WooCommerce order details?
Get an instance of the
WC_Orderobject usingwc_get_orderfunction.PHP12345678910111213141516$order = wc_get_order( $order_id );$order_id = $order->get_id(); // Get the order ID$parent_id = $order->get_parent_id(); // Get the parent order ID (for subscriptions…)$user_id = $order->get_user_id(); // Get the costumer ID$user = $order->get_user(); // Get the WP_User object$order_status = $order->get_status(); // Get the order status$currency = $order->get_currency(); // Get the currency used$payment_method = $order->get_payment_method(); // Get the payment method ID$payment_title = $order->get_payment_method_title(); // Get the payment method title$date_created = $order->get_date_created(); // Get date created (WC_DateTime object)$date_modified = $order->get_date_modified(); // Get date modified (WC_DateTime object)$billing_country = $order->get_billing_country();Get custom product attributes in Woocommerce
You can get the single value for the attribute with
post_meta(get_post_meta) function.PHP1get_post_meta($product->id, 'some_key_here', true);Get WooCommerce Products
PHP1234567891011121314$args = array('post_type' => 'product','posts_per_page' => 10,'product_cat' => 'hoodies');$loop = new WP_Query( $args );while ( $loop->have_posts() ) : $loop->the_post();global $product;echo '<br /><a href="'.get_permalink().'">' . woocommerce_get_product_thumbnail().' '.get_the_title().'</a>';endwhile;wp_reset_query();
-
-
AuthorPosts
Viewing 0 reply threads
- You must be logged in to reply to this topic.