calvinS
Support threads created in the last 30 days: 0
Favorite Forum Topics
This user has no favorite topics.
Forum Topics Created
Status | Topic | Supporter | Voices | Posts | Freshness |
---|---|---|---|---|---|
Export a result of view in CSV and Download as CSV
Started by: calvinS
in: Toolset Professional Support
Problem: Solution: You can find proposed solution, in this case, with the following reply: Relevant Documentation: |
2 | 2 | 6 years, 3 months ago | ||
Display Order Products and Quantities
Started by: calvinS
in: Toolset Professional Support
Problem: I have a View of WooCommerce Orders that shows the products in each order. I would also like to show the quantity of each product. Solution: At this time, there isn't a built-in way to do this, it's only possible to display each Product from the Order. I have a custom shortcode here that can help. Add this to your child theme's functions.php file: function order_product_qty_func($atts) { $a = shortcode_atts( array( 'orderid' => '', 'productid' => '' ), $atts ); // get the order using the orderid shortcode attribute $order = wc_get_order( $a['orderid'] ); // loop over the order items foreach ($order->get_items() as $item_id => $item_data) { // Get an instance of corresponding the WC_Product object $product = $item_data->get_product(); $product_id = $product->get_id(); // Get the product id // if the product id matches the current product id in the loop, return the qty if( $product_id == $a['productid'] ) return $item_data->get_quantity(); } return; } add_shortcode( 'order_product_qty', 'order_product_qty_func'); In the View of Ordered Products, add the Order ID to the View shortcode as an attribute like this: [wpv-view name="List of Ordered Products" ids="[wpv-ordered-product-ids]" orderid="[wpv-post-id]"] Then in the Loop Output of the Ordered Products View, you can access the orderid and include the new custom shortcode like this: [order_product_qty productid="[wpv-post-id]" orderid="[wpv-attribute name='orderid']"][/order_product_qty] Relevant Documentation: |
3 | 7 | 6 years, 7 months ago |