To fetch the order items you can use the method
get_items()
I am doing something similar to you and i am doing it like this
$order = wc_get_order($order_id);
$line_items = $order->get_items();
In WooCommerce 3.0, CRUD objects were added so all the data can be accessed using getters and set using setters. Line items are the same so when you have your line items you should loop them and access the data using getters.
For more information about the available getters and setters for these objects you can use this for reference https://docs.woocommerce.com/wp-content/images/wc-apidocs/class-WC_Order.html for the order object and for the product line items you can check https://docs.woocommerce.com/wc-apidocs/class-WC_Order_Item_Product.html
Hope this helps!
Related Posts:
- WooCommerce get Shipping Class of product from either the product id or the order after order is completed
- product-attribute-slug-is-too-long-28-characters-max
- get all products of one category
- Woocommerce add custom button to backend order table
- Plugin vs Settings load order (woocommerce dependency)
- How do I hook a custom discount to change a WC_Order price total on WooCommerce?
- Add multiple shipping rates from add_rate function with custom ID
- Print value of an array or variable in a payment plugin
- How to update total price of completed order in woocommerce? [closed]
- Plugin development: get_post_meta is not working [closed]
- $wpdb -> Batch insert from XML File?
- How do I change the initial quantity of a product in woocommerce?
- How to check if Woocommerce Order number equals to post ID?
- How do I add custom column to woocommerce cart?
- How plugins_loaded works?
- WooCommerce Conditional Tag inside plugin
- Custom attribute type not displaying terms in edit product – WooCommerce
- WooCommerce registration password field not displaying
- Show special field when correct shipping is chosen
- update woocommere total value on checkout based on selected payment method
- how to add custom functionality after woocommerce place order button
- Adding a brand column to WooCommerce Products
- Woocommerce checkout update totals with datepicker
- Strange issue saving custom field data for a WooCommerce order
- PHP – Extend WordPress Woocommerce Revenue Analytics with custom field
- Woocommerce – Convert Delivery method into a custom field
- “import declarations may only appear at top level of a module” when importing WooCommerce API node module
- Woocommerce extend tax report with custom column
- How can we display product price $104 on the cart while the credit card payment method is checked?
- In woocommerce cart item we can add custom text but how can i add custom link? [closed]
- Updating Woocommerce Settings API when WordPress Settings API saved and vise versa
- Can’t get woocommerce_get_price_html to work [closed]
- How to restrict access to image folder depending on whether product is purchased or not?
- How to extend WooCommerce API to show bookable product availability rules?
- Customize WooCommerce my account dashboard through plugin
- woocommerce_checkout_order_processed hook executing function twice
- Is there a way in which I can compare product id with the order id to display content on front end before placing the order? [closed]
- Woocommerce Composite Products – Add a composite product to cart programmatically via ajax [closed]
- Change WooCommerce Email Header using custom plugin
- UWooCommerce – add cart discount programmatically?
- How to get all product in the woo-commerce? [closed]
- Woocommerce inventory [closed]
- WooCommerce change Tax Class programmatically when Recalculating an existing Order [closed]
- Can woocommerse be used dynamically for billing from another plugin for payment processing?
- Can we use a library under MIT license in a WooCommerce plugin?
- WooCommerce Endpoints content
- How to call code when adding WooCommerce menu items via woocommerce_account_menu_items
- Duplicate shipping method logic to another shipping method [closed]
- Custom Plugin Options Won’t Update
- Hide one specific woocoomerce product
- Woocommerce – Provide Associated Category Link for Product List Plugin [closed]
- get_shipping_methods() return empty rate
- Remove Products From Category
- want to show CMB2 metabox on woocommerce product data tab
- wp_schedule_single_event is set correctly but sometimes not fired
- Customise Grouped Product display in Woocommerce with custom column
- Change reminder email date to 14 days before
- How to make every image title equal to alt text(wordpress/woocommerce)?
- Pass Values in URL on WooCommerce Product Page
- product-attribute-slug-is-too-long-28-characters-max
- Trying to run a Ajax request from a checkout form in woocommerce via a custom plugin
- “add to cart” links css class “ajax_add_to_cart” doesn’t show in woocommerce in widget sidebar
- Securing custom rest API endpoints with public access from PWA
- How do I add filter with woocommerce categories?
- WooCommerce – Stop assigning order numbers
- Adding customs fields on each product on the cart
- Override woocommerce loop-start.php from theme using plugin?
- Getting products information, in woocommerce based on products ID
- PHPUnit Testing and woocommerce Constant
- WC REST API Error Handling
- Pre-populated WooCommerce checkout fields: dropdown fields issue
- want to confirm popup with “Yes” and “No” button when user click on add to cart
- How to remove the WooCommerce Product->Category thumbnail from admin [closed]
- Woocommerce Single Product Tabs Got Duplicate
- woocommerce wc_get_product is not fetching all the product of particular category
- Override WooCommerce files from plugin
- woocommerce add a new bulk action in the bulk actions dropdown in the orders list
- How to trigger WooCommerce user profile edit change?
- WC_Geolocation not found inside plugin
- How to use functions from Woocommerce documentation?
- external Integration with wordpress timeout error
- how to retrieve post_id under woocommerce_add_to_cart_validation hook?
- Handle changed Woocommerce function
- Making Woocommerce optimized for more than 500k products
- Woo-commerce: Adding additional page sections using a child theme
- WP: adding Javascript to specific woo commerce pages
- Declaring a new woo commerce product type i get this error
- woocommerce single product page hook not working
- How to remove city field from order in dashboard?
- How to only Load scripts on variable products page
- How to design WooCommerce-like admin tabs for plugin settings page?
- Woocommerce: block user removing cart item
- how do I find out if a placed order was deleted or trashed? [closed]
- What is the meta_query key name for the woo product average rating? [closed]
- Trigger a JavaScript function based on the data fetched from Woo commerce hook
- Return custom product in ajax call loop
- WooCommerce adds a newline symbol (\n) between email recipients
- Allow HTML in product attributes and variation for WooCommerce
- How do I add multiple custom menu Woo-commerce my account page?
- I want to redirect user to an amazon product page from my wordpress website when they add product to there cart [closed]