rport

PHOTO EMBED

Mon Nov 27 2023 07:13:43 GMT+0000 (Coordinated Universal Time)

Saved by @dinovas #php

// Loop through each item in the order
                        // This loop processes each individual item within the order to extract its specific info
                        foreach ($order->get_items() as $item_id => $item) {

                            // Retrieve the ID of the product associated with the current item in the order
                            $product_id = $item->get_product_id();
                            // Check if the current item's product ID matches the product ID we're processing in this loop iteration
                            if ($product_id == $pid) {
                                // Get the total price and subtotal price specific to this order item
                                // These values are specific to each item in the order, rather than the order as a whole
                                $line_total = wc_get_order_item_meta($item_id, '_line_total', true);
                                $line_subtotal = wc_get_order_item_meta($item_id, '_line_subtotal', true);
                                // ... extract other relevant data ... for now the amounts are ok
            
                                // Build the report entry for this product
                                array_push($order_data,[
                                    'order_id'         => $order_id,
                                    'customer_first'   => $order->get_billing_first_name(),
                                    'customer_last'    => $order->get_billing_last_name(),
                                    'order_created'    => date("d/m/Y",strtotime($order->get_date_created())),
                                    'email'            => $order->get_billing_email(),
                                    'phone'            => $order->get_billing_phone(),
                                    'orders_status'    => $order_status,
                                    'invoice_no'       => $formatted_invoice_number,
                                    'credit_note'      => $credit_note,
                                    'invoice_date'     => $invoice_date,
                                    'credit_note_date' => $credit_note_date,//date("d/m/Y",strtotime($credit_note_date)),
                                    'wooco_currency'   => $currency_symbol,
                                    'gross'            => round($line_subtotal,2),
                                    'discount'         => round($order->get_total_discount(),2),
                                    'net_total'        => round($line_total,2),
                                    'course_id'        => self::get_product_sku($pid),
                                    'course_start'     => $course_start,
                                    'course_ends'      => $course_end,
                                    'student_id'       => $assign_student_id_value
                                ]);
                            }  
                        }
content_copyCOPY