/** * Use views to display the Orders page * * @return html */ public function display_product_orders() { if (!WCV_Vendors::is_vendor(get_current_user_id())) { ob_start(); wc_get_template('denied.php', array(), 'wc-vendors/dashboard/', wcv_plugin_dir . 'templates/dashboard/'); return ob_get_clean(); } if (empty($_GET['orders_for_product'])) { return __('You haven\'t selected a product\'s orders to view! Please go back to the Vendor Dashboard and click Show Orders on the product you\'d like to view.', 'wcvendors'); } if (!$this->orders) { return __('No orders.', 'wcvendors'); } if (!empty($_POST['submit_comment'])) { require_once wcv_plugin_dir . 'classes/front/orders/class-submit-comment.php'; WCV_Submit_Comment::new_comment($this->orders); } if (isset($_POST['mark_shipped'])) { $order_id = (int) $_POST['order_id']; $product_id = (int) $_POST['product_id']; exit; } if (isset($_POST['update_tracking'])) { $order_id = (int) $_POST['order_id']; $product_id = (int) $_POST['product_id']; $tracking_provider = woocommerce_clean($_POST['tracking_provider']); $custom_tracking_provider = woocommerce_clean($_POST['custom_tracking_provider']); $custom_tracking_link = woocommerce_clean($_POST['custom_tracking_link']); $tracking_number = woocommerce_clean($_POST['tracking_number']); $date_shipped = woocommerce_clean(strtotime($_POST['date_shipped'])); $order = new WC_Order($order_id); $products = $order->get_items(); foreach ($products as $key => $value) { if ($value['product_id'] == $product_id || $value['variation_id'] == $product_id) { $order_item_id = $key; break; } } if ($order_item_id) { woocommerce_delete_order_item_meta($order_item_id, __('Tracking number', 'wcvendors')); woocommerce_add_order_item_meta($order_item_id, __('Tracking number', 'wcvendors'), $tracking_number); $message = __('Success. Your tracking number has been updated.', 'wcvendors'); wc_add_notice($message, 'success'); // Update order data update_post_meta($order_id, '_tracking_provider', $tracking_provider); update_post_meta($order_id, '_custom_tracking_provider', $custom_tracking_provider); update_post_meta($order_id, '_tracking_number', $tracking_number); update_post_meta($order_id, '_custom_tracking_link', $custom_tracking_link); update_post_meta($order_id, '_date_shipped', $date_shipped); } } $headers = WCV_Orders::get_headers(); $all = WCV_Orders::format_order_details($this->orders, $this->product_id); wp_enqueue_style('pv_frontend_style', wcv_assets_url . 'css/wcv-frontend.css'); wp_enqueue_script('pv_frontend_script', wcv_assets_url . 'js/front-orders.js'); // WC Shipment Tracking Providers global $WC_Shipment_Tracking; $providers = !empty($WC_Shipment_Tracking->providers) ? $WC_Shipment_Tracking->providers : false; $provider_array = array(); if ($providers) { foreach ($providers as $providerss) { foreach ($providerss as $provider => $format) { $provider_array[sanitize_title($provider)] = urlencode($format); } } } // End ob_start(); // Show the Export CSV button if ($this->can_export_csv) { wc_get_template('csv-export.php', array(), 'wc-vendors/orders/', wcv_plugin_dir . 'templates/orders/'); } wc_get_template('orders.php', array('headers' => $headers, 'body' => $all['body'], 'items' => $all['items'], 'product_id' => $all['product_id'], 'providers' => $providers, 'provider_array' => $provider_array), 'wc-vendors/orders/', wcv_plugin_dir . 'templates/orders/'); return ob_get_clean(); }
/** * Use views to display the Orders page * * @return html */ public function display_product_orders() { if (!WCV_Vendors::is_vendor(get_current_user_id())) { ob_start(); wc_get_template('denied.php', array(), 'wc-vendors/dashboard/', wcv_plugin_dir . 'templates/dashboard/'); return ob_get_clean(); } if (empty($_GET['orders_for_product'])) { return __('You haven\'t selected a product\'s orders to view! Please go back to the Vendor Dashboard and click Show Orders on the product you\'d like to view.', 'wcvendors'); } if (!$this->orders) { return __('No orders.', 'wcvendors'); } if (!empty($_POST['submit_comment'])) { require_once wcv_plugin_dir . 'classes/front/orders/class-submit-comment.php'; WCV_Submit_Comment::new_comment($this->orders); } if (isset($_POST['mark_shipped'])) { $order_id = (int) $_POST['order_id']; $product_id = (int) $_POST['product_id']; exit; } $headers = WCV_Orders::get_headers(); $all = WCV_Orders::format_order_details($this->orders, $this->product_id); wp_enqueue_style('pv_frontend_style', wcv_assets_url . 'css/wcv-frontend.css'); wp_enqueue_script('pv_frontend_script', wcv_assets_url . 'js/front-orders.js'); $providers = array(); $provider_array = array(); // WC Shipment Tracking Providers if (class_exists('WC_Shipment_Tracking')) { $WC_Shipment_Tracking = new WC_Shipment_Tracking(); $providers = method_exists($WC_Shipment_Tracking, 'get_providers') ? $WC_Shipment_Tracking->get_providers() : $WC_Shipment_Tracking->providers; $provider_array = array(); foreach ($providers as $all_providers) { foreach ($all_providers as $provider => $format) { $provider_array[sanitize_title($provider)] = urlencode($format); } } } ob_start(); // Show the Export CSV button if ($this->can_export_csv) { wc_get_template('csv-export.php', array(), 'wc-vendors/orders/', wcv_plugin_dir . 'templates/orders/'); } wc_get_template('orders.php', array('headers' => $headers, 'body' => $all['body'], 'items' => $all['items'], 'product_id' => $all['product_id'], 'providers' => $providers, 'provider_array' => $provider_array), 'wc-vendors/orders/', wcv_plugin_dir . 'templates/orders/'); return ob_get_clean(); }