Security
Headlines
HeadlinesLatestCVEs

Headline

CVE-2020-36741: class-wcmp-vendor-dashboard.php in dc-woocommerce-multi-vendor/tags/3.5.8/classes – WordPress Plugin Repository

The MultiVendorX plugin for WordPress is vulnerable to Cross-Site Request Forgery in versions up to, and including, 3.5.7. This is due to missing or incorrect nonce validation on the submit_comment() function. This makes it possible for unauthenticated attackers to submit comments via a forged request granted they can trick a site administrator into performing an action such as clicking on a link.

CVE
#ios#google#js#git#java#wordpress#php#auth

1<?php23/**4 * WCMPp Vendor Admin Dashboard - Vendor WP-Admin Dashboard Pages5 * 6 * @version 2.2.07 * @package WCMp8 * @author WC Marketplace9 */10Class WCMp_Admin_Dashboard {1112 private $wcmp_vendor_order_page;13 /** @var string Currenct Step */14 private $step = '’;15 /** @var array Steps for the setup wizard */16 private $steps = array();17 private $vendor;18 function __construct() {1920 // Add Shop Settings page 21 add_action('admin_menu’, array($this, ‘vendor_dashboard_pages’));2223 add_action('woocommerce_product_options_shipping’, array($this, ‘wcmp_product_options_shipping’), 5);2425 add_action('wp_before_admin_bar_render’, array($this, ‘remove_admin_bar_links’));2627 add_action('wp_footer’, ‘wcmp_remove_comments_section_from_vendor_dashboard’);2829 add_action('wcmp_dashboard_setup’, array(&$this, ‘wcmp_dashboard_setup’), 5);30 add_action('wcmp_dashboard_widget’, array(&$this, ‘do_wcmp_dashboard_widget’));31 // Vendor store updater info32 add_action('wcmp_dashboard_setup’, array(&$this, ‘wcmp_dashboard_setup_updater’), 6);33 // Vendor save product34 if ( current_user_can( ‘edit_products’ ) ) {35 add_action( 'template_redirect’, array( &$this, ‘save_product’ ), 90 );36 }37 if ( current_vendor_can( ‘edit_shop_coupon’ ) ) {38 add_action( 'template_redirect’, array( &$this, ‘save_coupon’ ), 90 );39 }40 41 add_filter( 'wcmp_vendor_dashboard_add_product_url’, array( &$this, ‘wcmp_vendor_dashboard_add_product_url’ ), 10 );42 add_filter( 'wcmp_vendor_submit_product’, array( &$this, ‘wcmp_vendor_dashboard_add_product_url’ ), 10 );4344 // Submit comment45 add_action( 'before_wcmp_vendor_dashboard’, array( &$this, ‘submit_comment’ ) );4647 // Init export functions48 $this->export_csv();4950 $this->vendor_withdrawl();5152 $this->export_vendor_orders_csv();53 // vendor tools handler54 $this->vendor_tools_handler();55 // vendor updater handler56 $this->vendor_updater_handler();57 // save shipping data58 $this->backend_shipping_handler();59 // vendor store setup wizard60 $this->vendor_setup_wizard();61 }6263 function remove_admin_bar_links() {64 global $wp_admin_bar;65 if (!current_user_can(‘manage_options’)) {66 $wp_admin_bar->remove_menu(‘new-post’);67 $wp_admin_bar->remove_menu(‘new-dc_commission’);68 $wp_admin_bar->remove_menu(‘comments’);69 }70 }7172 /**73 * Vendor Commission withdrawl74 */75 public function vendor_withdrawl() {76 global $WCMp;77 if ($_SERVER[‘REQUEST_METHOD’] == ‘POST’) {78 if (isset($_POST[‘vendor_get_paid’])) {79 $vendor = get_wcmp_vendor(get_current_vendor_id());80 $commissions = isset($_POST[‘commissions’]) ? $_POST[‘commissions’] : array();81 if (!empty($commissions)) {82 $payment_method = get_user_meta($vendor->id, '_vendor_payment_mode’, true);83 if ($payment_method) {84 if (array_key_exists($payment_method, $WCMp->payment_gateway->payment_gateways)) {85 $response = $WCMp->payment_gateway->payment_gateways[$payment_method]->process_payment($vendor, $commissions, ‘manual’);86 if ($response) {87 if (isset($response[‘transaction_id’])) {88 do_action( 'wcmp_after_vendor_withdrawal_transaction_success’, $response[‘transaction_id’] );89 $redirect_url = wcmp_get_vendor_dashboard_endpoint_url(get_wcmp_vendor_settings('wcmp_transaction_details_endpoint’, 'vendor’, 'general’, ‘transaction-details’), $response[‘transaction_id’]);90 $notice = $this->get_wcmp_transaction_notice($response[‘transaction_id’]);91 if (isset($notice[‘type’])) {92 wc_add_notice($notice[‘message’], $notice[‘type’]);93 }94 wp_safe_redirect($redirect_url);95 exit;96 } else {97 foreach ($response as $message) {98 wc_add_notice($message[‘message’], $message[‘type’]);99 }100 }101 } else {102 wc_add_notice(__('Oops! Something went wrong please try again later’, ‘dc-woocommerce-multi-vendor’), ‘error’);103 }104 } else {105 wc_add_notice(__('Invalid payment method’, ‘dc-woocommerce-multi-vendor’), ‘error’);106 }107 } else {108 wc_add_notice(__('No payment method has been selected for commission withdrawal’, ‘dc-woocommerce-multi-vendor’), ‘error’);109 }110 } else {111 wc_add_notice(__('Please select atleast one or more commission.’, ‘dc-woocommerce-multi-vendor’), ‘error’);112 }113 }114 }115 }116117 public function get_wcmp_transaction_notice($transaction_id) {118 $transaction = get_post($transaction_id);119 $notice = array();120 switch ($transaction->post_status) {121 case 'wcmp_processing’:122 $notice = array(‘type’ => 'success’, ‘message’ => __('Your withdrawal request has been sent to the admin and your commission will be disbursed shortly!’, ‘dc-woocommerce-multi-vendor’));123 break;124 case 'wcmp_completed’:125 $notice = array(‘type’ => 'success’, ‘message’ => __('Congrats! You have successfully received your commission amount.’, ‘dc-woocommerce-multi-vendor’));126 break;127 case 'wcmp_canceled’:128 $notice = array(‘type’ => 'error’, ‘message’ => __('Oops something went wrong! Your commission withdrawal request was declined!’, ‘dc-woocommerce-multi-vendor’));129 break;130 default :131 break;132 }133 return apply_filters('wcmp_get_transaction_status_notice’, $notice, $transaction);134 }135136 /**137 * Export CSV from vendor dasboard page138 *139 * @access public140 * @return void141 */142 public function export_csv() {143 global $WCMp;144145 if ($_SERVER[‘REQUEST_METHOD’] == ‘POST’) {146147 if (isset($_POST[‘export_transaction’])) {148 $transaction_details = array();149 if (!empty($_POST[‘transaction_ids’])) {150 $date = date(‘Y-m-d’);151 $filename = 'TransactionReport-' . $date . '.csv’;152 header(“Pragma: public”);153 header(“Expires: 0”);154 header(“Cache-Control: must-revalidate, post-check=0, pre-check=0”);155 header(“Content-Type: application/force-download”);156 header(“Content-Type: application/octet-stream”);157 header(“Content-Type: application/download”);158 header(“Content-Disposition: attachment;filename={$filename}”);159 header(“Content-Transfer-Encoding: binary”);160 header(“Content-Type: charset=UTF-8”);161162 $headers = array(163 ‘date’ => __('Date’, ‘dc-woocommerce-multi-vendor’),164 ‘trans_id’ => __('Transaction ID’, ‘dc-woocommerce-multi-vendor’),165 ‘commission_ids’ => __('Commission IDs’, ‘dc-woocommerce-multi-vendor’),166 ‘mode’ => __('Mode’, ‘dc-woocommerce-multi-vendor’),167 ‘commission’ => __('Commission’, ‘dc-woocommerce-multi-vendor’),168 ‘fee’ => __('Fee’, ‘dc-woocommerce-multi-vendor’),169 ‘credit’ => __('Credit’, ‘dc-woocommerce-multi-vendor’),170 );171 if (!empty($_POST[‘transaction_ids’])) {172 foreach ($_POST[‘transaction_ids’] as $transaction_id) {173 $commission_details = get_post_meta($transaction_id, 'commission_detail’, true);174 $transfer_charge = get_post_meta($transaction_id, 'transfer_charge’, true) + get_post_meta($transaction_id, 'gateway_charge’, true);175 $transaction_amt = get_post_meta($transaction_id, 'amount’, true) - get_post_meta($transaction_id, 'transfer_charge’, true) - get_post_meta($transaction_id, 'gateway_charge’, true);176 $transaction_commission = get_post_meta($transaction_id, 'amount’, true);177178 $mode = get_post_meta($transaction_id, 'transaction_mode’, true);179 if ($mode == ‘paypal_masspay’ || $mode == ‘paypal_payout’) {180 $transaction_mode = __('PayPal’, ‘dc-woocommerce-multi-vendor’);181 } else if ($mode == ‘stripe_masspay’) {182 $transaction_mode = __('Stripe’, ‘dc-woocommerce-multi-vendor’);183 } else if ($mode == ‘direct_bank’) {184 $transaction_mode = __('Direct Bank Transfer’, ‘dc-woocommerce-multi-vendor’);185 } else {186 $transaction_mode = $mode;187 }188189 $order_datas[] = array(190 ‘date’ => get_the_date('Y-m-d’, $transaction_id),191 ‘trans_id’ => ‘#’ . $transaction_id,192 ‘commission_ids’ => ‘#’ . implode(', #’, $commission_details),193 ‘mode’ => $transaction_mode,194 ‘commission’ => $transaction_commission,195 ‘fee’ => $transfer_charge,196 ‘credit’ => $transaction_amt,197 );198 }199 }200201202 // Initiate output buffer and open file203 ob_start();204 $file = fopen(“php://output", ‘w’);205206 // Add headers to file207 fputcsv($file, $headers);208 // Add data to file209 if (!empty($order_datas)) {210 foreach ($order_datas as $order_data) {211 fputcsv($file, $order_data);212 }213 } else {214 fputcsv($file, array(__('Sorry. no transaction data is available upon your selection’, ‘dc-woocommerce-multi-vendor’)));215 }216217 // Close file and get data from output buffer218 fclose($file);219 $csv = ob_get_clean();220221 // Send CSV to browser for download222 echo $csv;223 die();224 } else {225 wc_add_notice(__('Please select atleast one and more transactions.’, ‘dc-woocommerce-multi-vendor’), ‘error’);226 }227 }228 $user = wp_get_current_user();229 $vendor = get_wcmp_vendor($user->ID);230 if (isset($_POST[‘wcmp_stat_export’]) && !empty($_POST[‘wcmp_stat_export’]) && $vendor && apply_filters('can_wcmp_vendor_export_orders_csv’, true, $vendor->id)) {231 $vendor = apply_filters('wcmp_order_details_export_vendor’, $vendor);232 $start_date = isset($_POST[‘wcmp_stat_start_dt’]) ? $_POST[‘wcmp_stat_start_dt’] : date(‘Y-m-01’);233 $end_date = isset($_POST[‘wcmp_stat_end_dt’]) ? $_POST[‘wcmp_stat_end_dt’] : date(‘Y-m-d’);234 $start_date = strtotime('-1 day’, strtotime($start_date));235 $end_date = strtotime('+1 day’, strtotime($end_date));236 $query = array(237 ‘date_query’ => array(238 array(239 ‘after’ => array(‘year’ => date('Y’, $start_date), ‘month’ => date('m’, $start_date), ‘day’ => date('d’, $start_date)),240 ‘before’ => array(‘year’ => date('Y’, $end_date), ‘month’ => date('m’, $end_date), ‘day’ => date('d’, $end_date)),241 ‘inclusive’ => true,242 )243 )244 );245 $records = $vendor->get_orders(false, false, $query);246 if (!empty($records) && is_array($records)) {247 $vendor_orders = array_unique($records);248 if (!empty($vendor_orders))249 $this->generate_csv($vendor_orders, $vendor);250 }251 }252 }253 }254255 public function generate_csv($customer_orders, $vendor, $args = array()) {256 global $WCMp;257 $order_datas = array();258 $index = 0;259 $date = date(‘Y-m-d’);260 $default = array(261 ‘filename’ => 'SalesReport-' . $date . '.csv’,262 ‘iostream’ => 'php://output’,263 ‘buffer’ => 'w’,264 ‘action’ => 'download’,265 );266 $args = wp_parse_args($args, $default);267268 $filename = $args[‘filename’];269 if ($args[‘action’] == ‘download’) {270 header(“Pragma: public”);271 header(“Expires: 0”);272 header(“Cache-Control: must-revalidate, post-check=0, pre-check=0”);273 header(“Content-Type: application/force-download”);274 header(“Content-Type: application/octet-stream”);275 header(“Content-Type: application/download”);276 header(“Content-Disposition: attachment;filename={$filename}”);277 header(“Content-Transfer-Encoding: binary”);278 }279280 $headers = apply_filters('wcmp_vendor_order_generate_csv_headers’, array(281 ‘order’ => __('Order’, ‘dc-woocommerce-multi-vendor’),282 ‘date_of_purchase’ => __('Date of Purchase’, ‘dc-woocommerce-multi-vendor’),283 ‘time_of_purchase’ => __('Time Of Purchase’, ‘dc-woocommerce-multi-vendor’),284 ‘vendor_name’ => __('Vendor Name’, ‘dc-woocommerce-multi-vendor’),285 ‘product’ => __('Items bought’, ‘dc-woocommerce-multi-vendor’),286 ‘qty’ => __('Quantity’, ‘dc-woocommerce-multi-vendor’),287 ‘discount_used’ => __('Discount Used’, ‘dc-woocommerce-multi-vendor’),288 ‘tax’ => __('Tax’, ‘dc-woocommerce-multi-vendor’),289 ‘shipping’ => __('Shipping’, ‘dc-woocommerce-multi-vendor’),290 ‘commission_share’ => __('Earning’, ‘dc-woocommerce-multi-vendor’),291 ‘payment_system’ => __('Payment System’, ‘dc-woocommerce-multi-vendor’),292 ‘buyer_name’ => __('Customer Name’, ‘dc-woocommerce-multi-vendor’),293 ‘buyer_email’ => __('Customer Email’, ‘dc-woocommerce-multi-vendor’),294 ‘buyer_contact’ => __('Customer Contact’, ‘dc-woocommerce-multi-vendor’),295 ‘billing_address’ => __('Billing Address Details’, ‘dc-woocommerce-multi-vendor’),296 ‘shipping_address’ => __('Shipping Address Details’, ‘dc-woocommerce-multi-vendor’),297 ‘order_status’ => __('Order Status’, ‘dc-woocommerce-multi-vendor’),298 ));299300 if (!apply_filters('show_customer_details_in_export_orders’, true, $vendor->id)) {301 unset($headers[‘buyer_name’]);302 unset($headers[‘buyer_email’]);303 unset($headers[‘buyer_contact’]);304 }305 if (!apply_filters('show_customer_billing_address_in_export_orders’, true, $vendor->id)) {306 unset($headers[‘billing_address’]);307 }308 if (!apply_filters('show_customer_shipping_address_in_export_orders’, true, $vendor->id)) {309 unset($headers[‘shipping_address’]);310 }311312 if ($vendor) {313 if (!empty($customer_orders)) {314 foreach ($customer_orders as $commission_id => $customer_order) {315 $order = wc_get_order($customer_order);316 $vendor_items = $vendor->get_vendor_items_from_order($customer_order, $vendor->term_id);317 $item_names = $item_qty = array();318 if (sizeof($vendor_items) > 0) {319 foreach ($vendor_items as $item) {320 $item_names[] = $item[‘name’];321 $item_qty[] = $item[‘quantity’];322 }323324 //coupons count325 $coupon_used = '’;326 $coupons = $order->get_items(‘coupon’);327 foreach ($coupons as $coupon_item_id => $item) {328 $coupon = new WC_Coupon(trim($item[‘name’]));329 $coupon_post = get_post($coupon->get_id());330 $author_id = $coupon_post->post_author;331 if ($vendor->id == $author_id) {332 $coupon_used .= $item[‘name’] . ', ';333 }334 }335336 // Formatted Addresses337 $formatted_billing_address = apply_filters('woocommerce_order_formatted_billing_address’, array(338 ‘address_1’ => $order->get_billing_address_1(),339 ‘address_2’ => $order->get_billing_address_2(),340 ‘city’ => $order->get_billing_city(),341 ‘state’ => $order->get_billing_state(),342 ‘postcode’ => $order->get_billing_postcode(),343 ‘country’ => $order->get_billing_country()344 ), $order);345 $formatted_billing_address = WC()->countries->get_formatted_address($formatted_billing_address);346347 $formatted_shipping_address = apply_filters('woocommerce_order_formatted_shipping_address’, array(348 ‘address_1’ => $order->get_shipping_address_1(),349 ‘address_2’ => $order->get_shipping_address_2(),350 ‘city’ => $order->get_shipping_city(),351 ‘state’ => $order->get_shipping_state(),352 ‘postcode’ => $order->get_shipping_postcode(),353 ‘country’ => $order->get_shipping_country()354 ), $order);355 $formatted_shipping_address = WC()->countries->get_formatted_address($formatted_shipping_address);356357 $customer_name = $order->get_billing_first_name() . ' ' . $order->get_billing_last_name();358 $customer_email = $order->get_billing_email();359 $customer_phone = $order->get_billing_phone();360361 $order_datas[$index] = apply_filters('wcmp_vendor_order_generate_csv_data’, array(362 ‘order’ => ‘#’ . $customer_order,363 ‘date_of_purchase’ => date_i18n('Y-m-d’, strtotime($order->get_date_created())),364 ‘time_of_purchase’ => date_i18n('H’, strtotime($order->get_date_created())) . ' : ' . date_i18n('i’, strtotime($order->get_date_created())),365 ‘vendor_name’ => $vendor->page_title,366 ‘product’ => implode(', ', $item_names),367 ‘qty’ => implode(', ', $item_qty),368 ‘discount_used’ => apply_filters('wcmp_export_discount_used_in_order’, $coupon_used),369 ‘tax’ => get_post_meta($commission_id, '_tax’, true),370 ‘shipping’ => get_post_meta($commission_id, '_shipping’, true),371 ‘commission_share’ => get_post_meta($commission_id, '_commission_amount’, true),372 ‘payment_system’ => $order->get_payment_method_title(),373 ‘buyer_name’ => $customer_name,374 ‘buyer_email’ => $customer_email,375 ‘buyer_contact’ => $customer_phone,376 ‘billing_address’ => str_replace('<br/>’, ', ', $formatted_billing_address),377 ‘shipping_address’ => str_replace('<br/>’, ', ', $formatted_shipping_address),378 ‘order_status’ => $order->get_status(),379 ), $customer_order, $vendor);380 if (!apply_filters('show_customer_details_in_export_orders’, true, $vendor->id)) {381 unset($order_datas[$index][‘buyer_name’]);382 unset($order_datas[$index][‘buyer_email’]);383 unset($order_datas[$index][‘buyer_contact’]);384 }385 if (!apply_filters('show_customer_billing_address_in_export_orders’, true, $vendor->id)) {386 unset($order_datas[$index][‘billing_address’]);387 }388 if (!apply_filters('show_customer_shipping_address_in_export_orders’, true, $vendor->id)) {389 unset($order_datas[$index][‘shipping_address’]);390 }391 $index++;392 }393 }394 }395 }396 // Initiate output buffer and open file397 ob_start();398 if ($args[‘action’] == ‘download’ && $args[‘iostream’] == ‘php://output’) {399 $file = fopen($args[‘iostream’], $args[‘buffer’]);400 } elseif ($args[‘action’] == ‘temp’ && $args[‘filename’]) {401 $filename = sys_get_temp_dir() . ‘/’ . $args[‘filename’];402 $file = fopen($filename, $args[‘buffer’]);403 }404 // Add headers to file405 fputcsv($file, $headers);406 // Add data to file407 foreach ($order_datas as $order_data) {408 if (!$WCMp->vendor_caps->vendor_capabilities_settings(‘is_order_show_email’) || apply_filters('is_not_show_email_field’, true)) {409 unset($order_data[‘buyer’]);410 }411 fputcsv($file, $order_data);412 }413414 // Close file and get data from output buffer415 fclose($file);416 $csv = ob_get_clean();417 if ($args[‘action’] == ‘temp’) {418 return $filename;419 } else {420 // Send CSV to browser for download421 echo $csv;422 die();423 }424 }425426 /**427 * Submit Comment 428 *429 * @access public430 * @return void431 */432 public function submit_comment() {433 global $WCMp;434 if ($_SERVER[‘REQUEST_METHOD’] == ‘POST’) {435 if (!empty($_POST[‘wcmp_submit_comment’])) {436 // verify nonce437 if ( !isset( $_POST[‘vendor_add_order_nonce’] ) || !wp_verify_nonce( $_POST[‘vendor_add_order_nonce’], ‘dc-vendor-add-order-comment’ ) )438 return false;439 $vendor = get_current_vendor();440 // Don’t submit empty comments441 if (empty($_POST[‘comment_text’]))442 return false;443 // Only submit if the order has the product belonging to this vendor444 $order = wc_get_order($_POST[‘order_id’]);445 $comment = esc_textarea($_POST[‘comment_text’]);446 $note_type = isset($_POST[‘note_type’]) ? $_POST[‘note_type’] : '’;447 $is_customer_note = ( ‘customer’ === $note_type ) ? 1 : 0;448 $comment_id = $order->add_order_note($comment, $is_customer_note, true);449 if( $is_customer_note ){450 $email_note = WC()->mailer()->emails[‘WC_Email_Customer_Note’];451 $email_note->trigger(array(452 ‘order_id’ => $order,453 ‘customer_note’ => $comment,454 ));455 }456 // update comment author & email457 wp_update_comment(array(‘comment_ID’ => $comment_id, ‘comment_author’ => $vendor->page_title, ‘comment_author_email’ => $vendor->user_data->user_email));458 add_comment_meta($comment_id, '_vendor_id’, $vendor->id);459 wc_add_notice(__('Order note added’, ‘dc-woocommerce-multi-vendor’), ‘success’);460 wp_redirect(esc_url(wcmp_get_vendor_dashboard_endpoint_url(get_wcmp_vendor_settings('wcmp_vendor_orders_endpoint’, 'vendor’, 'general’, ‘vendor-orders’), $order->get_id())));461 die();462 }463464 if (!empty($_POST[‘wcmp_submit_product_comment’])) {465 // verify nonce466 if ($_POST[‘vendor_add_product_nonce’] && !wp_verify_nonce($_POST[‘vendor_add_product_nonce’], ‘dc-vendor-add-product-comment’))467 return false;468 $user_id = $_POST[‘current_user_id’];469 // Don’t submit empty comments470 if (empty($_POST[‘product_comment_text’]))471 return false;472 // Only submit if the order has the product belonging to this vendor473 $product = wc_get_product($_POST[‘product_id’]);474 $comment = esc_textarea($_POST[‘product_comment_text’]);475 $comment_id = WCMp_Product::add_product_note($product->get_id(), $comment, $user_id);476 // update comment author & email477 add_comment_meta($comment_id, '_author_id’, $user_id);478 if(is_user_wcmp_vendor($user_id)) {479 wc_add_notice(__('Product note added’, ‘dc-woocommerce-multi-vendor’), ‘success’);480 wp_redirect(esc_url(wcmp_get_vendor_dashboard_endpoint_url(get_wcmp_vendor_settings('wcmp_vendor_orders_endpoint’, 'vendor’, 'general’, ‘edit-product’), $product->get_id())));481 } else {482 wp_safe_redirect(admin_url(‘post.php?post=’.$product->get_id().’&action=edit’));483 }484 die();485 }486 }487 }488489 /**490 * Vendor tools handler 491 *492 * @access public493 * @return void494 */495 public function vendor_tools_handler() {496 $vendor = get_current_vendor();497 $wpnonce = isset($_REQUEST[‘_wpnonce’]) ? $_REQUEST[‘_wpnonce’] : '’;498 $tools_action = isset($_REQUEST[‘tools_action’]) ? $_REQUEST[‘tools_action’] : '’;499 if ($wpnonce && wp_verify_nonce($wpnonce, ‘wcmp_clear_vendor_transients’) && $tools_action && $tools_action == ‘clear_all_transients’) {500 if (current_user_can(‘delete_published_products’)) {501 if ($vendor->clear_all_transients($vendor->id)) {502 wc_add_notice(__('Vendor transients cleared!’, ‘dc-woocommerce-multi-vendor’), ‘success’);503 }504 wp_redirect(esc_url(wcmp_get_vendor_dashboard_endpoint_url(get_wcmp_vendor_settings('wcmp_vendor_tools_endpoint’, 'vendor’, 'general’, ‘vendor-tools’))));505 die();506 }507 }508 // 509 do_action('wcmp_vendor_tools_handler’, $tools_action, $wpnonce);510 }511512 public function vendor_dashboard_pages() {513 $user = wp_get_current_user();514 $vendor = get_wcmp_vendor($user->ID);515 $vendor = apply_filters('wcmp_vendor_dashboard_pages_vendor’, $vendor);516 if ($vendor) {517 $shipping_page = apply_filters('wcmp_vendor_view_shipping_page’, true);518 if ($vendor->is_shipping_enable() && $shipping_page) {519 $shipping_hook = add_menu_page(__('Shipping’, ‘dc-woocommerce-multi-vendor’), __('Shipping’, ‘dc-woocommerce-multi-vendor’), 'read’, 'dc-vendor-shipping’, array($this, ‘shipping_page’));520 }521 }522 }523524 /**525 * HTML setup for the Orders Page 526 */527 public static function shipping_page() {528 global $WCMp;529 $zone_id = isset($_REQUEST[‘zone_id’]) ? absint($_REQUEST[‘zone_id’]) : 0;530 $zones = array();531 532 $vendor_user_id = apply_filters('wcmp_dashboard_shipping_vendor’, get_current_vendor_id());533534 ?>535 <div class="wrap">536 <div id="icon-woocommerce” class="icon32 icon32-woocommerce-reports"><br/></div>537 <h2><?php _e('Shipping’, ‘dc-woocommerce-multi-vendor’); ?></h2>538 <form name="vendor_shipping_form" method="post">539 <?php wp_nonce_field( 'backend_vendor_shipping_data’, ‘vendor_shipping_data’ ); ?>540 <?php 541 if ($zone_id) {542 if( !class_exists( ‘WCMP_Shipping_Zone’ ) ) {543 $WCMp->load_vendor_shipping();544 }545 $zones = WCMP_Shipping_Zone::get_zone($zone_id);546 if ($zones)547 $zone = WC_Shipping_Zones::get_zone(absint($zone_id));548 // Load scripts549 $WCMp->localize_script(‘wcmp_vendor_shipping’);550 wp_enqueue_script(‘wcmp_vendor_shipping’);551552 if (!$zones) {553 ?>554 <p><?php _e('No shipping zone found for configuration. Please contact with admin for manage your store shipping’, ‘dc-woocommerce-multi-vendor’); ?></p>555 <?php556 } elseif ($zones) {557 // for specific zone shipping methods settings558559 $show_post_code_list = $show_state_list = $show_post_code_list = false;560561 $zone_id = $zones[‘data’][‘id’];562 $zone_locations = $zones[‘data’][‘zone_locations’];563564 $zone_location_types = array_column(array_map('wcmp_convert_to_array’, $zone_locations), 'type’, ‘code’);565566 $selected_continent_codes = array_keys($zone_location_types, ‘continent’);567568 if (!$selected_continent_codes) {569 $selected_continent_codes = array();570 }571572 $selected_country_codes = array_keys($zone_location_types, ‘country’);573 $all_states = WC()->countries->get_states();574575 $state_key_by_country = array();576 $state_key_by_country = array_intersect_key($all_states, array_flip($selected_country_codes));577578 array_walk($state_key_by_country, ‘wcmp_state_key_alter’);579580 $state_key_by_country = call_user_func_array('array_merge’, $state_key_by_country);581582 $show_limit_location_link = apply_filters('show_limit_location_link’, (!in_array('postcode’, $zone_location_types)));583 $vendor_shipping_methods = $zones[‘shipping_methods’];584585 if ($show_limit_location_link) {586 if (in_array('state’, $zone_location_types)) {587 $show_city_list = apply_filters('wcmp_city_select_dropdown_enabled’, false);588 $show_post_code_list = true;589 } elseif (in_array('country’, $zone_location_types)) {590 $show_state_list = true;591 $show_city_list = apply_filters('wcmp_city_select_dropdown_enabled’, false);592 $show_post_code_list = true;593 }594 }595596 $want_to_limit_location = !empty($zones[‘locations’]);597 $countries = $states = $cities = array();598 $postcodes = '’;599 if ($want_to_limit_location) {600 $postcodes = array();601 foreach ($zones[‘locations’] as $each_location) {602 switch ($each_location[‘type’]) {603 case 'state’:604 $states[] = $each_location[‘code’];605 break;606 case 'postcode’:607 $postcodes[] = $each_location[‘code’];608 break;609 default:610 break;611 }612 }613 614 $postcodes = implode(',’, $postcodes);615 }616 617 ?>618 <input id="zone_id" class="form-control" type="hidden" name="<?php echo 'wcmp_shipping_zone[' . $zone_id . '][_zone_id]'; ?>" value="<?php echo $zone_id; ?>">619 <table class="form-table wcmp-shipping-zone-settings wc-shipping-zone-settings">620 <tbody>621 <tr valign="top" class="">622 <th scope="row" class="titledesc">623 <label for="">624 <?php _e('Zone Name’, ‘dc-woocommerce-multi-vendor’); ?>625 </label>626 </th>627 <td class="forminp"><?php _e($zones[‘data’][‘zone_name’], ‘dc-woocommerce-multi-vendor’); ?></td>628 </tr>629 <tr valign="top" class="">630 <th scope="row" class="titledesc">631 <label for="">632 <?php _e('Zone region’, ‘dc-woocommerce-multi-vendor’); ?>633 </label>634 </th>635 <td class="forminp"><?php _e($zones[‘formatted_zone_location’], ‘dc-woocommerce-multi-vendor’); ?></td>636 </tr>637 <?php if ($show_limit_location_link && $zone_id !== 0) { ?>638 <tr valign="top" class="">639 <th scope="row" class="titledesc">640 <label for="">641 <?php _e('Limit Zone Location’, ‘dc-woocommerce-multi-vendor’); ?>642 </label>643 </th>644 <td class="forminp"><input id="limit_zone_location" class="form-control" type="checkbox" name="<?php echo 'wcmp_shipping_zone[' . $zone_id . '][_limit_zone_location]'; ?>" value="1" <?php checked($want_to_limit_location, 1); ?>></td>645 </tr>646 <?php } ?>647 <?php if ($show_state_list) { ?>648 <tr valign="top" class="hide_if_zone_not_limited">649 <th scope="row" class="titledesc">650 <label for="">651 <?php _e('Select specific states’, ‘dc-woocommerce-multi-vendor’); ?>652 </label>653 </th>654 <td class="forminp">655 <select id="select_zone_states" class="form-control" name="<?php echo 'wcmp_shipping_zone[' . $zone_id . '][_select_zone_states][]'; ?>" multiple>656 <?php foreach ($state_key_by_country as $key => $value) { ?>657 <option value="<?php echo $key; ?>" <?php selected(in_array($key, $states), true); ?>><?php echo $value; ?></option>658 <?php } ?>659 </select>660 </td>661 </tr>662 <?php } ?>663 <?php if ($show_post_code_list) { ?>664 <tr valign="top" class="hide_if_zone_not_limited">665 <th scope="row" class="titledesc">666 <label for="">667 <?php _e('Set your postcode’, ‘dc-woocommerce-multi-vendor’); ?>668 </label>669 </th>670 <td class="forminp">671 <input id="select_zone_postcodes" class="form-control" type="text" name="<?php echo 'wcmp_shipping_zone[' . $zone_id . '][_select_zone_postcodes]'; ?>" value="<?php echo $postcodes; ?>" placeholder="<?php _e('Postcodes need to be comma separated’, ‘dc-woocommerce-multi-vendor’); ?>">672 </td>673 </tr>674 <?php } ?>675 <tr valign="top" class="">676 <th scope="row" class="titledesc">677 <label>678 <?php _e('Shipping methods’, ‘dc-woocommerce-multi-vendor’); ?>679 <?php echo wc_help_tip(__('Add your shipping method for appropiate zone’, ‘dc-woocommerce-multi-vendor’)); // @codingStandardsIgnoreLine ?>680 </label>681 </th>682 <td class="">683 <table class="wcmp-shipping-zone-methods wc-shipping-zone-methods widefat">684 <thead>685 <tr> 686 <th class="wcmp-title wc-shipping-zone-method-title"><?php _e('Title’, ‘dc-woocommerce-multi-vendor’); ?></th>687 <th class="wcmp-enabled wc-shipping-zone-method-enabled"><?php _e('Enabled’, ‘dc-woocommerce-multi-vendor’); ?></th> 688 <th class="wcmp-description wc-shipping-zone-method-description"><?php _e('Description’, ‘dc-woocommerce-multi-vendor’); ?></th>689 <th class="wcmp-action"><?php _e('Action’, ‘dc-woocommerce-multi-vendor’); ?></th>690 </tr>691 </thead>692 <tfoot>693 <tr>694 <td colspan="4">695 <button type="submit" class="button wcmp-shipping-zone-show-method wc-shipping-zone-add-method" value="<?php esc_attr_e('Add shipping method’, ‘woocommerce’); ?>"><?php esc_html_e('Add shipping method’, ‘woocommerce’); ?></button>696 </td>697 </tr>698 </tfoot>699 <tbody>700 <?php if (empty($vendor_shipping_methods)) { ?> 701 <tr>702 <td colspan="4"><?php _e(‘You can add multiple shipping methods within this zone. Only customers within the zone will see them.’, ‘dc-woocommerce-multi-vendor’); ?></td>703 </tr>704 <?php705 } else { 706 foreach ($vendor_shipping_methods as $vendor_shipping_method) {707 ?>708 <tr class="wcmp-shipping-zone-method">709 <td><?php _e($vendor_shipping_method[‘title’], ‘wcmp’); ?>710 <div data-instance_id="<?php echo $vendor_shipping_method[‘instance_id’]; ?>" data-method_id="<?php echo $vendor_shipping_method[‘id’]; ?>" data-method-settings=’<?php echo json_encode($vendor_shipping_method); ?>’ class="row-actions edit_del_actions">711 </div>712 </td>713 <td class="wcmp-shipping-zone-method-enabled wc-shipping-zone-method-enabled"> 714 <span class="wcmp-input-toggle woocommerce-input-toggle woocommerce-input-toggle–<?php echo ($vendor_shipping_method[‘enabled’] == “yes”) ? ‘enabled’ : 'disabled’; ?>">715 <input id="method_status" class="input-checkbox method-status" type="checkbox" name="method_status" value="<?php echo $vendor_shipping_method[‘instance_id’]; ?>" <?php checked(( $vendor_shipping_method[‘enabled’] == “yes”), true); ?>>716 </span>717 </td>718 <td><?php _e($vendor_shipping_method[‘settings’][‘description’], ‘dc-woocommerce-multi-vendor’); ?></td>719 <td>720 <div class="col-actions edit_del_actions" data-instance_id="<?php echo $vendor_shipping_method[‘instance_id’]; ?>" data-method_id="<?php echo $vendor_shipping_method[‘id’]; ?>" data-method-settings=’<?php echo json_encode($vendor_shipping_method); ?>’>721 <span class="edit"><a href="javascript:void(0);" class="edit-shipping-method" data-zone_id="<?php echo $zone_id; ?>" data-method_id="<?php echo $vendor_shipping_method[‘id’]; ?>" data-instance_id="<?php echo $vendor_shipping_method[‘instance_id’]; ?>" title="<?php _e('Edit’, ‘dc-woocommerce-multi-vendor’) ?>"><?php _e('Edit’, ‘dc-woocommerce-multi-vendor’) ?></a>722 </span>|723 <span class="delete"><a class="delete-shipping-method" href="javascript:void(0);" data-method_id="<?php echo $vendor_shipping_method[‘id’]; ?>" data-instance_id="<?php echo $vendor_shipping_method[‘instance_id’]; ?>" title="<?php _e('Delete’, ‘dc-woocommerce-multi-vendor’) ?>"><?php _e('Delete’, ‘dc-woocommerce-multi-vendor’) ?></a></span>724 </div>725 </td>726 </tr>727 <?php728 }729 }730 ?>731 </tbody>732 </table>733 </td>734 </tr>735 </tbody>736 737 <script type="text/template" id="tmpl-wcmp-modal-add-shipping-method">738 <div class="wc-backbone-modal wcmp-modal-add-shipping-method-modal">739 <div class="wc-backbone-modal-content">740 <section class="wc-backbone-modal-main" role="main">741 <header class="wc-backbone-modal-header">742 <h1><?php esc_html_e('Add shipping method’, ‘dc-woocommerce-multi-vendor’); ?></h1>743 <button class="modal-close modal-close-link dashicons dashicons-no-alt">744 <span class="screen-reader-text"><?php esc_html_e('Close modal panel’, ‘dc-woocommerce-multi-vendor’); ?></span>745 </button>746 </header>747 <article>748 <form action="" method="post">749 <input type="hidden" name="zone_id" value="<?php echo $zone_id; ?>"/>750 <div class="wc-shipping-zone-method-selector">751 <p><?php esc_html_e('Choose the shipping method you wish to add. Only shipping methods which support zones are listed.’, ‘dc-woocommerce-multi-vendor’); ?></p>752 <?php $shipping_methods = wcmp_get_shipping_methods(); ?>753 <select id="shipping_method" class="form-control mt-15" name="wcmp_shipping_method">754 <?php foreach ($shipping_methods as $key => $method) { ?>755 <option data-description="<?php echo esc_attr( wp_kses_post( wpautop( $method->get_method_description() ) ) ); ?>" value="<?php echo esc_attr( $method->id ); ?>"><?php echo esc_attr( $method->get_method_title() ); ?></option>756 <?php } ?>757 </select>758 <div class="wc-shipping-zone-method-description"></div>759 </div>760 </form>761 </article>762 <footer>763 <div class="inner">764 <button id="btn-ok" class="button button-primary button-large wcmp-shipping-zone-add-method" data-zone_id="<?php echo $zone_id; ?>"><?php esc_html_e('Add shipping method’, ‘dc-woocommerce-multi-vendor’); ?></button>765 </div>766 </footer>767 </section>768 </div>769 </div>770 <div class="wc-backbone-modal-backdrop modal-close"></div>771 </script>772 <script type="text/template" id="tmpl-wcmp-modal-update-shipping-method">773 <?php774 global $WCMp;775776 $is_method_taxable_array = array(777 ‘none’ => __('None’, ‘dc-woocommerce-multi-vendor’),778 ‘taxable’ => __('Taxable’, ‘dc-woocommerce-multi-vendor’)779 );780781 $calculation_type = array(782 ‘class’ => __('Per class: Charge shipping for each shipping class individually’, ‘dc-woocommerce-multi-vendor’),783 ‘order’ => __('Per order: Charge shipping for the most expensive shipping class’, ‘dc-woocommerce-multi-vendor’),784 );785 ?>786 <div class="wc-backbone-modal wcmp-modal-add-shipping-method-modal">787 <div class="wc-backbone-modal-content">788 <section class="wc-backbone-modal-main" role="main">789 <header class="wc-backbone-modal-header">790 <h1><?php _e( 'Edit Shipping Methods’, ‘dc-woocommerce-multi-vendor’ ); ?></h1>791 <button class="modal-close modal-close-link dashicons dashicons-no-alt">792 <span class="screen-reader-text"><?php esc_html_e('Close modal panel’, ‘dc-woocommerce-multi-vendor’); ?></span>793 </button>794 </header>795 <article class="wcmp-shipping-methods">796 <form action="" method="post">797 <input id="instance_id_selected" class="form-control" type="hidden" name="zone_id" value="<?php echo $zone_id; ?>"> 798 <input id="method_id_selected" class="form-control" type="hidden" name="method_id" value="{{{ data.methodId }}}"> 799 <input id="instance_id_selected" class="form-control" type="hidden" name="instance_id" value="{{{ data.instanceId }}}"> 800 {{{ data.config_settings }}}801 802 </form>803 </article>804 <footer>805 <div class="inner">806 <button id="btn-ok" class="button button-primary button-large wcmp-shipping-zone-add-method" data-zone_id="<?php echo $zone_id; ?>"><?php esc_html_e('Save changes’, ‘dc-woocommerce-multi-vendor’); ?></button>807 </div>808 </footer>809 </section>810 </div>811 </div>812 <div class="wc-backbone-modal-backdrop modal-close"></div>813 </script>814 </table>815 <?php }816 817 } else { ?>818 <table class="wcmp-shipping-zones wc-shipping-zones widefat">819 <thead>820 <tr>821 <th><?php _e('Zone name’, ‘dc-woocommerce-multi-vendor’); ?></th> 822 <th><?php _e('Region(s)', ‘dc-woocommerce-multi-vendor’); ?></th> 823 <th><?php _e('Shipping method(s)', ‘dc-woocommerce-multi-vendor’); ?></th>824 <th><?php _e('Actions’, ‘dc-woocommerce-multi-vendor’); ?></th>825 </tr>826 </thead>827 <tbody class="wcmp-shipping-zone-rows wc-shipping-zone-rows">828 <?php $vendor_all_shipping_zones = wcmp_get_shipping_zone();829 if (!empty($vendor_all_shipping_zones)) {830 foreach ($vendor_all_shipping_zones as $key => $vendor_shipping_zones) {831 ?>832 <tr data-id="0" class="wc-shipping-zone-worldwide">833 <td class="wc-shipping-zone-name">834 <a href="<?php echo esc_url(admin_url(‘admin.php?page=dc-vendor-shipping&zone_id=’ . $vendor_shipping_zones[‘zone_id’])); ?>" data-zone-id="<?php echo $vendor_shipping_zones[‘zone_id’]; ?>" class="vendor_edit_zone modify-shipping-methods"><?php _e($vendor_shipping_zones[‘zone_name’], ‘dc-woocommerce-multi-vendor’); ?></a> 835 </td>836 <td class="wc-shipping-zone-region"><?php _e($vendor_shipping_zones[‘formatted_zone_location’], ‘dc-woocommerce-multi-vendor’); ?></td>837 <td class="wc-shipping-zone-methods">838 <ul class="wcmp-shipping-zone-methods">839 <?php840 $vendor_shipping_methods = $vendor_shipping_zones[‘shipping_methods’];841 $vendor_shipping_methods_titles = array();842 if ($vendor_shipping_methods) :843 foreach ($vendor_shipping_methods as $key => $shipping_method) {844 $class_name = ‘yes’ === $shipping_method[‘enabled’] ? ‘method_enabled’ : 'method_disabled’;845 $vendor_shipping_methods_titles[] = “<li class=’wcmp-shipping-zone-method wc-shipping-zone-method $class_name’>” . $shipping_method[‘title’] . “</li>";846 }847 endif;848 //$vendor_shipping_methods_titles = array_column($vendor_shipping_methods, ‘title’);849 $vendor_shipping_methods_titles = implode('’, $vendor_shipping_methods_titles);850851 if (empty($vendor_shipping_methods)) {852 ?>853 <li class="wcmp-shipping-zone-method wc-shipping-zone-method"><?php _e('No shipping methods offered to this zone.’, ‘dc-woocommerce-multi-vendor’); ?> </li>854 <?php } else { ?>855 <?php _e($vendor_shipping_methods_titles, ‘dc-woocommerce-multi-vendor’); ?>856 <?php } ?>857 </ul>858 </td>859 <td>860 <div class="col-actions">861 <span class="view">862 <a href="<?php echo esc_url(admin_url(‘admin.php?page=dc-vendor-shipping&zone_id=’ . $vendor_shipping_zones[‘zone_id’])); ?>” data-zone-id="<?php echo $vendor_shipping_zones[‘zone_id’]; ?>" class="vendor_edit_zone modify-shipping-methods" title="<?php _e('Edit’, ‘dc-woocommerce-multi-vendor’); ?>"><?php _e('Edit’, ‘dc-woocommerce-multi-vendor’); ?></a>863 </span> 864 </div>865 </td>866 </tr>867 <?php868 }869 } else {870 ?>871 <tr>872 <td colspan="3"><?php _e('No shipping zone found for configuration. Please contact with admin for manage your store shipping’, ‘dc-woocommerce-multi-vendor’); ?></td>873 </tr>874 <?php }875 ?>876 </tbody>877 </table>878 <?php }879 ?>880 <?php do_action(‘wcmp_vendor_shipping_settings’); ?>881 <?php if(isset($_GET[‘zone_id’])) submit_button(); ?>882 </form>883884 <br class="clear"/>885 </div>886 <?php887 }888 889 public function backend_shipping_handler(){890 global $WCMp;891 if ($_SERVER[‘REQUEST_METHOD’] == ‘POST’) {892 if ( isset( $_POST[‘vendor_shipping_data’] ) && wp_verify_nonce( $_POST[‘vendor_shipping_data’], ‘backend_vendor_shipping_data’ ) ) {893 $all_allowed_countries = WC()->countries->get_allowed_countries();894 $location = array();895 $zone_id = 0;896 if (!empty($_POST[‘wcmp_shipping_zone’])) {897 foreach ($_POST[‘wcmp_shipping_zone’] as $shipping_zone) {898 if (isset($shipping_zone[‘_zone_id’]) && $shipping_zone[‘_zone_id’] != 0) {899 $zone_id = $shipping_zone[‘_zone_id’];900901 if (isset($shipping_zone[‘_limit_zone_location’]) && $shipping_zone[‘_limit_zone_location’]) {902 if (!empty($shipping_zone[‘_select_zone_states’])) {903 $state_array = array();904 foreach ($shipping_zone[‘_select_zone_states’] as $zone_state) {905 $state_array[] = array(906 ‘code’ => $zone_state,907 ‘type’ => 'state’908 );909 }910911 $location = array_merge($location, $state_array);912 }913914 if (!empty($shipping_zone[‘_select_zone_postcodes’])) {915 $postcode_array = array();916 $zone_postcodes = array_map('trim’, explode(',’, $shipping_zone[‘_select_zone_postcodes’]));917 foreach ($zone_postcodes as $zone_postcode) {918 $postcode_array[] = array(919 ‘code’ => $zone_postcode,920 ‘type’ => 'postcode’921 );922 }923924 $location = array_merge($location, $postcode_array);925 }926 }927 }928 }929 }930 if( !class_exists( ‘WCMP_Shipping_Zone’ ) ) {931 $WCMp->load_vendor_shipping();932 }933 WCMP_Shipping_Zone::save_location($location, $zone_id);934935 $WCMp->load_class(‘shipping-gateway’);936 WCMp_Shipping_Gateway::load_class(‘shipping-method’);937 $vendor_shipping = new WCMP_Vendor_Shipping_Method();938 $vendor_shipping->process_admin_options();939 // clear shipping transient940 WC_Cache_Helper::get_transient_version('shipping’, true);941 echo ‘<div class="updated settings-error notice is-dismissible"><p><strong>’ . __(“Shipping Data Updated", ‘dc-woocommerce-multi-vendor’) . '</strong></p></div>’;942 }943 944 }945 }946947 /**948 *949 *950 * @param unknown $status951 * @param unknown $option952 * @param unknown $value953 *954 * @return unknown955 */956 public static function set_table_option($status, $option, $value) {957 if ($option == ‘orders_per_page’) {958 return $value;959 }960 }961962 /**963 * Generate Orders Page view 964 */965 public function wcmp_vendor_orders_page() {966 $this->wcmp_vendor_order_page->wcmp_prepare_order_page_items();967 ?>968 <div class="wrap">969970 <div id="icon-woocommerce” class="icon32 icon32-woocommerce-reports"><br/></div>971 <h2><?php _e('Orders’, ‘dc-woocommerce-multi-vendor’); ?></h2>972973 <form id="posts-filter" method="get">974975 <input type="hidden" name="page" value="dc-vendor-orders"/>976 <?php $this->wcmp_vendor_order_page->display(); ?>977978 </form>979 <div id="ajax-response"></div>980 <br class="clear"/>981 </div>982 <?php983 }984985 function wcmp_product_options_shipping() {986 global $post;987 if (!is_user_wcmp_vendor(get_current_user_id())) {988 return;989 }990 $product_object = wc_get_product($post->ID);991 $args = array(992 ‘taxonomy’ => 'product_shipping_class’,993 ‘hide_empty’ => 0,994 ‘meta_query’ => array(995 array(996 ‘key’ => 'vendor_id’,997 ‘value’ => get_current_vendor_id(),998 ‘compare’ => '=’999 )1000 ),1001 ‘show_option_none’ => __('No shipping class’, ‘dc-woocommerce-multi-vendor’),1002 ‘name’ => 'product_shipping_class’,1003 ‘id’ => 'product_shipping_class’,1004 ‘selected’ => $product_object->get_shipping_class_id(‘edit’),1005 ‘class’ => 'select short’,1006 );1007 ?>1008 <p class="form-field dimensions_field">1009 <label for="product_shipping_class"><?php _e('Shipping class’, ‘dc-woocommerce-multi-vendor’); ?></label>1010 <?php wp_dropdown_categories($args); ?>1011 <?php echo wc_help_tip(__('Shipping classes are used by certain shipping methods to group similar products.’, ‘dc-woocommerce-multi-vendor’)); ?>1012 </p>1013 <script type="text/javascript">1014 jQuery(‘#product_shipping_class’).closest(“p”).remove();1015 </script>1016 <?php1017 }10181019 public function export_vendor_orders_csv() {1020 global $wpdb;1021 if ($_SERVER[‘REQUEST_METHOD’] == ‘POST’) {1022 if (isset($_POST[‘wcmp_download_vendor_order_csv’])) {1023 $vendor = get_current_vendor();1024 $order_data = array();1025 $order_ids = isset($_POST[‘selected_orders’]) ? $_POST[‘selected_orders’] : array();1026 if ($order_ids && count($order_ids) > 0) {1027 foreach ($order_ids as $order_id) {1028 $vorder = wcmp_get_order($order_id);1029 if($vorder){1030 $commission_id = $vorder->get_prop(‘_commission_id’);1031 $order_data[$commission_id] = $order_id;1032 }1033 1034 }1035 if (!empty($order_data)) {1036 $this->generate_csv($order_data, $vendor);1037 }1038 } else {1039 wc_add_notice(__('Please select atleast one and more order.’, ‘dc-woocommerce-multi-vendor’), ‘error’);1040 }1041 }1042 }1043 }10441045 public function is_order_shipped($order_id, $vendor) {1046 global $WCMp, $wpdb;1047 $shipping_status = $wpdb->get_results(“SELECT DISTINCT shipping_status from `{$wpdb->prefix}wcmp_vendor_orders` where vendor_id = " . $vendor->id . " AND order_id = " . $order_id, ARRAY_A);1048 $shipping_status = $shipping_status[0][‘shipping_status’];1049 if ($shipping_status == 0)1050 return false;1051 if ($shipping_status == 1)1052 return true;1053 }10541055 public function save_store_settings($user_id, $post) {1056 global $WCMp;1057 $vendor = get_wcmp_vendor($user_id);1058 $fields = $WCMp->user->get_vendor_fields($user_id);1059 foreach ($fields as $fieldkey => $value) {10601061 if (isset($post[$fieldkey])) {1062 if ($fieldkey == “vendor_page_slug” && !empty($post[$fieldkey])) {1063 if ($vendor && !$vendor->update_page_slug(wc_clean($_POST[$fieldkey]))) {1064 if (is_admin()) {1065 echo _e('Slug already exists’, ‘dc-woocommerce-multi-vendor’);1066 } else {1067 $err_msg = __('Slug already exists’, ‘dc-woocommerce-multi-vendor’);1068 return $err_msg;1069 }1070 } else {1071 update_user_meta($user_id, ‘_’ . $fieldkey, wc_clean($post[$fieldkey]));1072 }1073 continue;1074 }1075 if ($fieldkey == “vendor_page_slug” && empty($post[$fieldkey])) {1076 if (is_admin()) {1077 echo _e('Slug can not be empty’, ‘dc-woocommerce-multi-vendor’);1078 } else {1079 $err_msg = __('Slug can not be empty’, ‘dc-woocommerce-multi-vendor’);1080 return $err_msg;1081 }1082 }10831084 if ($fieldkey == ‘vendor_description’) {1085 update_user_meta($user_id, ‘_’ . $fieldkey, $post[$fieldkey]);1086 } elseif ($fieldkey == ‘vendor_country’) {1087 $country_code = $post[$fieldkey];1088 $country_data = WC()->countries->get_countries();1089 $country_name = ( isset($country_data[$country_code]) ) ? $country_data[$country_code] : $country_code; //To get country name by code1090 update_user_meta($user_id, ‘_’ . $fieldkey, $country_name);1091 update_user_meta($user_id, ‘_’ . $fieldkey . '_code’, $country_code);1092 } elseif ($fieldkey == ‘vendor_state’) {1093 $country_code = $post[‘vendor_country’];1094 $state_code = $post[$fieldkey];1095 $state_data = WC()->countries->get_states($country_code);1096 $state_name = ( isset($state_data[$state_code]) ) ? $state_data[$state_code] : $state_code; //to get State name by state code1097 update_user_meta($user_id, ‘_’ . $fieldkey, $state_name);1098 update_user_meta($user_id, ‘_’ . $fieldkey . '_code’, $state_code);1099 } else {1100 // social url validation1101 if (in_array($fieldkey, array('vendor_fb_profile’, 'vendor_twitter_profile’, 'vendor_google_plus_profile’, 'vendor_linkdin_profile’, 'vendor_youtube’, ‘vendor_instagram’))) {1102 if (!empty($post[$fieldkey]) && filter_var($post[$fieldkey], FILTER_VALIDATE_URL)) {1103 update_user_meta($user_id, ‘_’ . $fieldkey, $post[$fieldkey]);1104 } else {1105 update_user_meta($user_id, ‘_’ . $fieldkey, ‘’);1106 }1107 } else {1108 update_user_meta($user_id, ‘_’ . $fieldkey, $post[$fieldkey]);1109 }1110 }1111 if ($fieldkey == ‘vendor_page_title’ && empty($post[$fieldkey])) {1112 if (is_admin()) {1113 echo _e('Shop Title can not be empty’, ‘dc-woocommerce-multi-vendor’);1114 } else {1115 $err_msg = __('Shop Title can not be empty’, ‘dc-woocommerce-multi-vendor’);1116 return $err_msg;1117 }1118 }1119 if ($fieldkey == ‘vendor_page_title’) {1120 if (!$vendor->update_page_title(wc_clean($post[$fieldkey]))) {1121 if (is_admin()) {1122 echo _e('Shop Title Update Error’, ‘dc-woocommerce-multi-vendor’);1123 } else {1124 $err_msg = __('Shop Title Update Error’, ‘dc-woocommerce-multi-vendor’);1125 return $err_msg;1126 }1127 } else {1128 if (apply_filters('wcmp_update_user_display_name_with_vendor_store_name’, false, $user_id)) {1129 wp_update_user(array(‘ID’ => $user_id, ‘display_name’ => $post[$fieldkey]));1130 }1131 }1132 }1133 }1134 }1135 if (isset($_POST[‘_shop_template’]) && !empty($_POST[‘_shop_template’])) {1136 update_user_meta($user_id, '_shop_template’, $_POST[‘_shop_template’]);1137 }1138 if (isset($_POST[‘_store_location’]) && !empty($_POST[‘_store_location’])) {1139 update_user_meta($user_id, '_store_location’, $_POST[‘_store_location’]);1140 }1141 if (isset($_POST[‘store_address_components’]) && !empty($_POST[‘store_address_components’])) {1142 $address_components = wcmp_get_geocoder_components(json_decode(stripslashes($_POST[‘store_address_components’]), true));1143 if (isset($_POST[‘_store_location’]) && !empty($_POST[‘_store_location’])) {1144 $address_components[‘formatted_address’] = $_POST[‘_store_location’];1145 }1146 if (isset($_POST[‘_store_lat’]) && !empty($_POST[‘_store_lat’])) {1147 $address_components[‘latitude’] = $_POST[‘_store_lat’];1148 }1149 if (isset($_POST[‘_store_lng’]) && !empty($_POST[‘_store_lng’])) {1150 $address_components[‘longitude’] = $_POST[‘_store_lng’];1151 }1152 update_user_meta($user_id, '_store_address_components’, $address_components);1153 }1154 if (isset($_POST[‘_store_lat’]) && !empty($_POST[‘_store_lat’])) {1155 update_user_meta($user_id, '_store_lat’, $_POST[‘_store_lat’]);1156 }1157 if (isset($_POST[‘_store_lng’]) && !empty($_POST[‘_store_lng’])) {1158 update_user_meta($user_id, '_store_lng’, $_POST[‘_store_lng’]);1159 }1160 if (isset($_POST[‘timezone_string’]) && !empty($_POST[‘timezone_string’])) {1161 if (!empty($_POST[‘timezone_string’]) && preg_match('/^UTC[±]/’, $_POST[‘timezone_string’])) {1162 $_POST[‘gmt_offset’] = $_POST[‘timezone_string’];1163 $_POST[‘gmt_offset’] = preg_replace('/UTC\+?/’, '’, $_POST[‘gmt_offset’]);1164 $_POST[‘timezone_string’] = '’;1165 } else {1166 $_POST[‘gmt_offset’] = 0;1167 }1168 update_user_meta($user_id, 'timezone_string’, $_POST[‘timezone_string’]);1169 update_user_meta($user_id, 'gmt_offset’, $_POST[‘gmt_offset’]);1170 }1171 do_action('wcmp_save_custom_store_data’, $user_id, $post);1172 }11731174 /**1175 * Save Vendor Shipping data1176 * @global type $WCMp1177 * @param type $vendor_user_id1178 * @param type $post1179 */1180 public function save_vendor_shipping($vendor_user_id, $post) {1181 global $WCMp;1182 $all_allowed_countries = WC()->countries->get_allowed_countries();1183 $location = array();1184 $zone_id = 0;1185 if (!empty($_POST[‘wcmp_shipping_zone’])) {1186 foreach ($_POST[‘wcmp_shipping_zone’] as $shipping_zone) {1187 if (isset($shipping_zone[‘_zone_id’]) && $shipping_zone[‘_zone_id’] != 0) {1188 $zone_id = $shipping_zone[‘_zone_id’];11891190 if (isset($shipping_zone[‘_limit_zone_location’]) && $shipping_zone[‘_limit_zone_location’]) {1191 if (!empty($shipping_zone[‘_select_zone_states’])) {1192 $state_array = array();1193 foreach ($shipping_zone[‘_select_zone_states’] as $zone_state) {1194 $state_array[] = array(1195 ‘code’ => $zone_state,1196 ‘type’ => 'state’1197 );1198 }11991200 $location = array_merge($location, $state_array);1201 }12021203 if (!empty($shipping_zone[‘_select_zone_postcodes’])) {1204 $postcode_array = array();1205 $zone_postcodes = array_map('trim’, explode(',’, $shipping_zone[‘_select_zone_postcodes’]));1206 foreach ($zone_postcodes as $zone_postcode) {1207 $postcode_array[] = array(1208 ‘code’ => $zone_postcode,1209 ‘type’ => 'postcode’1210 );1211 }12121213 $location = array_merge($location, $postcode_array);1214 }1215 }1216 }1217 }1218 }1219 if( !class_exists( ‘WCMP_Shipping_Zone’ ) ) {1220 $WCMp->load_vendor_shipping();1221 }1222 WCMP_Shipping_Zone::save_location($location, $zone_id);12231224 $WCMp->load_class(‘shipping-gateway’);1225 WCMp_Shipping_Gateway::load_class(‘shipping-method’);1226 $vendor_shipping = new WCMP_Vendor_Shipping_Method();1227 $vendor_shipping->process_admin_options();12281229 // clear shipping transient1230 WC_Cache_Helper::get_transient_version('shipping’, true);12311232 }12331234 /**1235 * Save Vendor Profile data1236 * @since 3.1.01237 * @global type $WCMp1238 * @param type $vendor_user_id1239 * @param type $post1240 */1241 public function save_vendor_profile($vendor_user_id, $post) {1242 global $WCMp;1243 if (isset($_POST[‘vendor_profile_data’])) {1244 // preventing auth cookies from actually being sent to the client.1245 add_filter('send_auth_cookies’, ‘__return_false’);12461247 $current_user = get_user_by(‘id’, $vendor_user_id);1248 $has_error = false;1249 $userdata = array(1250 ‘ID’ => $vendor_user_id,1251 //’user_email’ => $_POST[‘vendor_profile_data’][‘user_email’],1252 ‘first_name’ => $_POST[‘vendor_profile_data’][‘first_name’],1253 ‘last_name’ => $_POST[‘vendor_profile_data’][‘last_name’],1254 );12551256 $pass_cur = !empty( $_POST[‘vendor_profile_data’][‘password_current’] ) ? $_POST[‘vendor_profile_data’][‘password_current’] : '’;1257 $pass1 = !empty( $_POST[‘vendor_profile_data’][‘password_1’] ) ? $_POST[‘vendor_profile_data’][‘password_1’] : '’;1258 $pass2 = !empty( $_POST[‘vendor_profile_data’][‘password_2’] ) ? $_POST[‘vendor_profile_data’][‘password_2’] : '’;1259 $email = !empty( $_POST[‘vendor_profile_data’][‘user_email’] ) ? $_POST[‘vendor_profile_data’][‘user_email’] : '’;1260 $save_pass = true;1261 1262 if ( $email ) {1263 $account_email = sanitize_email( $email );1264 if ( ! is_email( $account_email ) ) {1265 $has_error = true;1266 wc_add_notice( __( 'Please provide a valid email address.’, ‘woocommerce’ ), ‘error’ );1267 } elseif ( email_exists( $account_email ) && $account_email !== $current_user->user_email ) {1268 $has_error = true;1269 wc_add_notice( __( 'This email address is already registered.’, ‘woocommerce’ ), ‘error’ );1270 }1271 $userdata[‘user_email’] = $account_email;1272 }12731274 if (!empty($pass_cur) && empty($pass1) && empty($pass2)) {1275 $has_error = true;1276 wc_add_notice( __('Please fill out all password fields.’, ‘dc-woocommerce-multi-vendor’), ‘error’ );1277 $save_pass = false;1278 } elseif (!empty($pass1) && empty($pass_cur)) {1279 $has_error = true;1280 wc_add_notice( __('Please enter your current password.’, ‘dc-woocommerce-multi-vendor’), ‘error’ );1281 $save_pass = false;1282 } elseif (!empty($pass1) && empty($pass2)) {1283 $has_error = true;1284 wc_add_notice( __('Please re-enter your password.’, ‘dc-woocommerce-multi-vendor’), ‘error’ );1285 $save_pass = false;1286 } elseif ((!empty($pass1) || !empty($pass2) ) && $pass1 !== $pass2) {1287 $has_error = true;1288 wc_add_notice( __('New passwords do not match.’, ‘dc-woocommerce-multi-vendor’), ‘error’ );1289 $save_pass = false;1290 } elseif (!empty($pass1) && !wp_check_password($pass_cur, $current_user->user_pass, $current_user->ID)) {1291 $has_error = true;1292 wc_add_notice( __('Your current password is incorrect.’, ‘dc-woocommerce-multi-vendor’), ‘error’ );1293 $save_pass = false;1294 }1295 1296 if( $has_error ) return;12971298 if ($pass1 && $save_pass) {1299 $userdata[‘user_pass’] = $pass1;1300 }13011302 $user_id = wp_update_user($userdata);13031304 $profile_updt = update_user_meta($vendor_user_id, '_vendor_profile_image’, $_POST[‘vendor_profile_data’][‘vendor_profile_image’]);13051306 if ($profile_updt || $user_id) {1307 wc_add_notice( __('Profile Data Updated’, ‘dc-woocommerce-multi-vendor’), ‘success’ );1308 }1309 }1310 }13111312 /**1313 * Add vendor dashboard header navigation1314 * @since 3.0.01315 */1316 public function dashboard_header_nav() {1317 $vendor = get_current_vendor();1318 $header_nav = array(1319 ‘shop-link’ => array(1320 ‘label’ => __('My Shop’, ‘dc-woocommerce-multi-vendor’)1321 , ‘url’ => apply_filters('wcmp_vendor_shop_permalink’, esc_url($vendor->permalink))1322 , ‘class’ => '’1323 , ‘capability’ => true1324 , ‘position’ => 101325 , ‘link_target’ => '_blank’1326 , ‘nav_icon’ => 'wcmp-font ico-my-shop-icon’1327 ),1328 ‘add-product’ => array(1329 ‘label’ => __('Add Product’, ‘dc-woocommerce-multi-vendor’)1330 , ‘url’ => apply_filters('wcmp_vendor_submit_product’, esc_url(wcmp_get_vendor_dashboard_endpoint_url(get_wcmp_vendor_settings('wcmp_add_product_endpoint’, 'vendor’, 'general’, ‘add-product’))))1331 , ‘class’ => '’1332 , ‘capability’ => apply_filters('wcmp_vendor_dashboard_menu_add_product_capability’, ‘edit_products’)1333 , ‘position’ => 201334 , ‘link_target’ => '_self’1335 , ‘nav_icon’ => 'wcmp-font ico-product-icon’1336 ),1337 ‘orders’ => array(1338 ‘label’ => __('Orders’, ‘dc-woocommerce-multi-vendor’)1339 , ‘url’ => esc_url(wcmp_get_vendor_dashboard_endpoint_url(get_wcmp_vendor_settings('wcmp_vendor_orders_endpoint’, 'vendor’, 'general’, ‘vendor-orders’)))1340 , ‘class’ => '’1341 , ‘capability’ => true1342 , ‘position’ => 301343 , ‘link_target’ => '_self’1344 , ‘nav_icon’ => 'wcmp-font ico-orders-icon’1345 ),1346 ‘announcement’ => array(1347 ‘label’ => __('Announcement’, ‘dc-woocommerce-multi-vendor’)1348 , ‘url’ => esc_url(wcmp_get_vendor_dashboard_endpoint_url(get_wcmp_vendor_settings('wcmp_vendor_announcements_endpoint’, 'vendor’, 'general’, ‘vendor-announcements’)))1349 , ‘class’ => '’1350 , ‘capability’ => apply_filters('wcmp_show_vendor_announcements’, true)1351 , ‘position’ => 401352 , ‘link_target’ => '_self’1353 , ‘nav_icon’ => 'wcmp-font ico-announcement-icon’1354 )1355 );1356 return apply_filters('wcmp_vendor_dashboard_header_nav’, $header_nav);1357 }13581359 /**1360 * Add vendor dashboard header right panel navigation1361 * @since 3.0.01362 */1363 public function dashboard_header_right_panel_nav() {1364 $panel_nav = array(1365 ‘storefront’ => array(1366 ‘label’ => __('Storefront’, ‘dc-woocommerce-multi-vendor’)1367 , ‘url’ => esc_url(wcmp_get_vendor_dashboard_endpoint_url(get_wcmp_vendor_settings('wcmp_store_settings_endpoint’, 'vendor’, 'general’, ‘storefront’)))1368 , ‘class’ => '’1369 , ‘capability’ => true1370 , ‘position’ => 101371 , ‘link_target’ => '_self’1372 , ‘nav_icon’ => 'wcmp-font ico-storefront-icon’1373 ),1374 ‘profile’ => array(1375 ‘label’ => __('Profile management’, ‘dc-woocommerce-multi-vendor’)1376 , ‘url’ => esc_url(wcmp_get_vendor_dashboard_endpoint_url(get_wcmp_vendor_settings('wcmp_profile_endpoint’, 'vendor’, 'general’, ‘profile’)))1377 , ‘class’ => '’1378 , ‘capability’ => true1379 , ‘position’ => 201380 , ‘link_target’ => '_self’1381 , ‘nav_icon’ => 'wcmp-font ico-user-icon’1382 ),1383 ‘wp-admin’ => array(1384 ‘label’ => __('WordPress backend’, ‘dc-woocommerce-multi-vendor’)1385 , ‘url’ => esc_url(admin_url())1386 , ‘class’ => '’1387 , ‘capability’ => true1388 , ‘position’ => 301389 , ‘link_target’ => '_self’1390 , ‘nav_icon’ => 'wcmp-font ico-wp-backend-icon’1391 ),1392 ‘logout’ => array(1393 ‘label’ => __('Logout’, ‘dc-woocommerce-multi-vendor’)1394 , ‘url’ => esc_url(wp_logout_url(get_permalink(wcmp_vendor_dashboard_page_id())))1395 , ‘class’ => '’1396 , ‘capability’ => true1397 , ‘position’ => 401398 , ‘link_target’ => '_self’1399 , ‘nav_icon’ => 'wcmp-font ico-logout-icon’1400 )1401 );1402 return apply_filters('wcmp_vendor_dashboard_header_right_panel_nav’, $panel_nav);1403 }14041405 /**1406 * Add vendor dashboard widgets1407 * @since 3.0.01408 */1409 public function wcmp_dashboard_setup() {1410 $vendor = get_wcmp_vendor(get_current_user_id());1411 $this->wcmp_add_dashboard_widget('wcmp_vendor_stats_reports’, '’, array(&$this, ‘wcmp_vendor_stats_reports’), ‘full’);1412 $trans_details_widget_args = array();1413 if (apply_filters('wcmp_vendor_dashboard_menu_vendor_withdrawal_capability’, false)) {1414 $trans_details_widget_args[‘action’] = array(‘title’ => __('Withdrawal’, ‘dc-woocommerce-multi-vendor’), ‘link’ => esc_url(wcmp_get_vendor_dashboard_endpoint_url(get_wcmp_vendor_settings('wcmp_vendor_withdrawal_endpoint’, 'vendor’, 'general’, ‘vendor-withdrawal’))));1415 }1416 $this->wcmp_add_dashboard_widget('wcmp_vendor_transaction_details’, __('Transaction Details’, ‘dc-woocommerce-multi-vendor’), array(&$this, ‘wcmp_vendor_transaction_details’), 'side’, array(), $trans_details_widget_args);1417 $visitor_map_filter_attr = apply_filters('wcmp_vendor_visitors_map_filter_attr’, array(1418 ‘7’ => __('Last 7 days’, ‘dc-woocommerce-multi-vendor’),1419 ‘30’ => __('Last 30 days’, ‘dc-woocommerce-multi-vendor’),1420 ));1421 $visitor_map_filter = '<div class="widget-action-area pull-right">1422 <select id="wcmp_visitor_stats_date_filter” class="form-control">’;1423 if ($visitor_map_filter_attr) {1424 foreach ($visitor_map_filter_attr as $key => $value) {1425 $visitor_map_filter .= ‘<option value="’ . $key . ‘">’ . $value . '</option>’;1426 }1427 }1428 $visitor_map_filter .= '</select>1429 </div>’;1430 if(!apply_filters('wcmp_is_disable_store_visitors_stats’, false))1431 $this->wcmp_add_dashboard_widget('wcmp_vendor_visitors_map’, __('Visitors Map’, ‘dc-woocommerce-multi-vendor’), array(&$this, ‘wcmp_vendor_visitors_map’), 'normal’, '’, array(‘action’ => array(‘html’ => $visitor_map_filter)));1432 if ($vendor->is_shipping_enable()):1433 $this->wcmp_add_dashboard_widget('wcmp_vendor_pending_shipping’, __('Pending Shipping’, ‘dc-woocommerce-multi-vendor’), array(&$this, ‘wcmp_vendor_pending_shipping’));1434 endif;1435 if (current_user_can(‘edit_products’)) {1436 $this->wcmp_add_dashboard_widget('wcmp_vendor_product_stats’, __('Product Stats’, ‘dc-woocommerce-multi-vendor’), array(&$this, ‘wcmp_vendor_product_stats’), 'side’, '’, array(‘action’ => array(‘title’ => __('Add Product’, ‘dc-woocommerce-multi-vendor’), ‘link’ => apply_filters( 'wcmp_vendor_dashboard_add_product_url’, wcmp_get_vendor_dashboard_endpoint_url( get_wcmp_vendor_settings( 'wcmp_add_product_endpoint’, 'vendor’, 'general’, ‘add-product’ ))))));1437 $this->wcmp_add_dashboard_widget('wcmp_vendor_product_sales_report’, __('Product Sales Report’, ‘dc-woocommerce-multi-vendor’), array(&$this, ‘wcmp_vendor_product_sales_report’));1438 }1439 if (get_wcmp_vendor_settings('is_sellerreview’, ‘general’) == ‘Enable’) {1440 $this->wcmp_add_dashboard_widget('wcmp_customer_reviews’, __('Reviews’, ‘dc-woocommerce-multi-vendor’), array(&$this, ‘wcmp_customer_review’));1441 }1442 $this->wcmp_add_dashboard_widget('wcmp_vendor_products_cust_qna’, __('Customer Questions’, ‘dc-woocommerce-multi-vendor’), array(&$this, ‘wcmp_vendor_products_cust_qna’), 'side’, '’, array(‘action’ => array(‘title’ => __('Show All Q&As’, ‘dc-woocommerce-multi-vendor’), ‘link’ => esc_url(wcmp_get_vendor_dashboard_endpoint_url(get_wcmp_vendor_settings('wcmp_vendor_products_qnas_endpoint’, 'vendor’, 'general’, ‘products-qna’))))));1443 }14441445 /**1446 * Register new vendor dashboard widget1447 * @global array $wcmp_dashboard_widget1448 * @param string $widget_id1449 * @param string $widget_title1450 * @param callable $callback1451 * @param string $context1452 * @param int $priority1453 * @param array $callback_args1454 * @since 3.0.01455 */1456 public function wcmp_add_dashboard_widget($widget_id, $widget_title, $callback, $context = 'normal’, $callback_args = null, $args = array()) {1457 global $wcmp_dashboard_widget;1458 if (!is_user_wcmp_vendor(get_current_vendor_id())) {1459 return;1460 }1461 if (!isset($wcmp_dashboard_widget)) {1462 $wcmp_dashboard_widget = array();1463 }1464 if (!isset($wcmp_dashboard_widget[$context])) {1465 $wcmp_dashboard_widget[$context] = array();1466 }1467 $wcmp_dashboard_widget[$context][$widget_id] = array(1468 ‘id’ => $widget_id,1469 ‘title’ => $widget_title,1470 ‘callback’ => $callback,1471 ‘calback_args’ => $callback_args,1472 ‘args’ => $args1473 );1474 }14751476 /**1477 * Output vendor dashboard widgets1478 * @global array $wcmp_dashboard_widget1479 * @since 3.0.01480 */1481 public function do_wcmp_dashboard_widget($place) {1482 global $wcmp_dashboard_widget;1483 if (!$wcmp_dashboard_widget) {1484 return;1485 }1486 $wcmp_dashboard_widget = apply_filters('before_wcmp_dashboard_widget’, $wcmp_dashboard_widget);1487 if ($wcmp_dashboard_widget) {1488 foreach ($wcmp_dashboard_widget as $context => $dashboard_widget) {1489 if ($place == $context) {1490 foreach ($dashboard_widget as $widget_id => $widget) {1491 echo '<div class="panel panel-default pannel-outer-heading wcmp-dash-widget ' . $widget_id . '">’;1492 $this->build_widget_header($widget[‘title’], $widget[‘args’]);1493 echo '<div class="panel-body">’;1494 call_user_func($widget[‘callback’], $widget[‘calback_args’]);1495 echo '</div>’;1496 $this->build_widget_footer($widget[‘args’]);1497 echo '</div>’;1498 }1499 }1500 }1501 }1502 }15031504 public function build_widget_header($title, $args = array()) {1505 $default = array(1506 ‘icon’ => '’,1507 ‘action’ => array()1508 );1509 $args = array_merge($default, $args);1510 if (!empty($title)) {1511 ?>1512 <div class="panel-heading">1513 <h3 class="pull-left">1514 <?php if (!empty($args[‘icon’])) : ?>1515 <span class="icon_stand dashicons-before <?php echo $args[‘icon’]; ?>"></span>1516 <?php endif; ?>1517 <?php echo $title; ?>1518 </h3>1519 </div>1520 <div class="clearfix"></div>1521 <?php1522 }1523 }15241525 public function build_widget_footer($args = array()) {1526 $default = array(1527 ‘icon’ => '’,1528 ‘action’ => array()1529 );1530 $args = array_merge($default, $args);1531 if (!empty($args[‘action’])) {1532 ?>1533 <div class="panel-footer">1534 <?php if (isset($args[‘action’][‘link’]) && isset($args[‘action’][‘title’])) { ?>1535 <a href="<?php echo $args[‘action’][‘link’]; ?>" class="footer-link">1536 <?php1537 if (isset($args[‘action’][‘icon’])) {1538 echo '<span class="icon_stand dashicons-before ' . $args[‘action’][‘icon’] . '"></span>’;1539 }1540 ?>1541 <?php echo $args[‘action’][‘title’]; ?>1542 <i class="wcmp-font ico-right-arrow-icon"></i>1543 </a>1544 <?php1545 } if (isset($args[‘action’][‘html’])) {1546 echo $args[‘action’][‘html’];1547 }1548 ?>1549 </div>1550 <div class="clearfix"></div>1551 <?php1552 }1553 }15541555 public function wcmp_vendor_stats_reports($args = array()) {1556 global $WCMp;1557 $vendor = get_current_vendor();1558 $vendor_report_data = get_wcmp_vendor_dashboard_stats_reports_data();1559 $default_data = array();1560 $default_data[‘stats_reports_periods’] = apply_filters('wcmp_vendor_stats_reports_periods’, array(1561 ‘7’ => __('Last 7 days’, ‘dc-woocommerce-multi-vendor’),1562 ‘30’ => __('Last 30 days’, ‘dc-woocommerce-multi-vendor’),1563 ));1564 $default_data[‘vendor_report_data’] = $vendor_report_data;1565 $default_data[‘payment_mode’] = ucwords(str_replace('_’, ' ', $vendor->payment_mode));1566 $WCMp->template->get_template('vendor-dashboard/dashboard-widgets/wcmp_vendor_stats_reports.php’, $default_data);1567 }15681569 public function wcmp_vendor_pending_shipping($args = array()) {1570 global $WCMp;1571 $vendor = get_wcmp_vendor(get_current_user_id());1572 $today = @date('Y-m-d 00:00:00’, strtotime(“+1 days”));1573 $last_seven_day_date = date(‘Y-m-d H:i:s’, strtotime('-7 days’));1574 // Mark as shipped1575 if (isset($_POST[‘wcmp-submit-mark-as-ship’])) {1576 $order_id = $_POST[‘order_id’];1577 $tracking_id = $_POST[‘tracking_id’];1578 $tracking_url = $_POST[‘tracking_url’];1579 $vendor->set_order_shipped($order_id, $tracking_id, $tracking_url);1580 }15811582 $default_headers = apply_filters('wcmp_vendor_pending_shipping_table_header’, array(1583 ‘order_id’ => __('Order ID’, ‘dc-woocommerce-multi-vendor’),1584 ‘products_name’ => __('Product’, ‘dc-woocommerce-multi-vendor’),1585 ‘order_date’ => __('Order Date’, ‘dc-woocommerce-multi-vendor’),1586 ‘shipping_address’ => __('Address’, ‘dc-woocommerce-multi-vendor’),1587 ‘shipping_amount’ => __('Charges’, ‘dc-woocommerce-multi-vendor’),1588 ‘action’ => __('Action’, ‘dc-woocommerce-multi-vendor’),1589 ));1590 $WCMp->template->get_template('vendor-dashboard/dashboard-widgets/wcmp_vendor_pending_shipping.php’, array(‘default_headers’ => $default_headers));1591 }15921593 public function wcmp_customer_review() {1594 global $WCMp, $wpdb;1595 $WCMp->template->get_template(‘vendor-dashboard/dashboard-widgets/wcmp_customer_review.php’);1596 }15971598 public function wcmp_vendor_product_stats($args = array()) {1599 global $WCMp, $wpdb;1600 $publish_products_count = $pending_products_count = $draft_products_count = $trashed_products_count = 0;1601 $vendor = get_wcmp_vendor(get_current_user_id());1602 $args = array(‘post_status’ => array('publish’, 'pending’, 'draft’, ‘trash’));1603 $product_stats = array();1604 if($vendor) :1605 $where = “AND ({$wpdb->prefix}posts.post_status = ‘publish’ OR {$wpdb->prefix}posts.post_status = ‘draft’ OR {$wpdb->prefix}posts.post_status = ‘pending’ OR {$wpdb->prefix}posts.post_status = ‘trash’)“;1606 $products = $vendor->get_products_ids( array( ‘where’ => $where ) );1607 $product_stats[‘total_products’] = count($products);1608 foreach ( $products as $product) {1609 if ( get_post_status( $product->ID ) == ‘publish’ )1610 $publish_products_count += 1;1611 if ( get_post_status( $product->ID ) == ‘pending’ )1612 $pending_products_count += 1;1613 if ( get_post_status( $product->ID ) == ‘draft’ )1614 $draft_products_count += 1;1615 if ( get_post_status( $product->ID ) == ‘trash’ )1616 $trashed_products_count += 1;1617 }1618 endif;1619 $product_stats[‘publish_products_count’] = $publish_products_count;1620 $product_stats[‘pending_products_count’] = $pending_products_count;1621 $product_stats[‘draft_products_count’] = $draft_products_count;1622 $product_stats[‘trashed_products_count’] = $trashed_products_count;1623 $product_stats[‘product_page_url’] = wcmp_get_vendor_dashboard_endpoint_url(get_wcmp_vendor_settings('wcmp_products_endpoint’, 'vendor’, 'general’, ‘products’));16241625 $WCMp->template->get_template('vendor-dashboard/dashboard-widgets/wcmp_vendor_product_stats.php’, $product_stats);1626 1627 }16281629 public function wcmp_vendor_product_sales_report() {1630 global $WCMp;1631 $WCMp->template->get_template(‘vendor-dashboard/dashboard-widgets/wcmp_vendor_product_sales_report.php’);1632 }16331634 function wcmp_vendor_transaction_details() {1635 global $WCMp;1636 $total_amount = 0;1637 $transaction_display_array = array();1638 $vendor = get_wcmp_vendor(get_current_vendor_id());1639 $requestData = $_REQUEST;1640 $vendor = apply_filters('wcmp_transaction_vendor’, $vendor);1641 $start_date = isset($requestData[‘from_date’]) ? $requestData[‘from_date’] : date(‘01-m-Y’);1642 $end_date = isset($requestData[‘to_date’]) ? $requestData[‘to_date’] : date(‘t-m-Y’);1643 $transaction_details = $WCMp->transaction->get_transactions($vendor->term_id);1644 $unpaid_commission_total = WCMp_Commission::get_unpaid_commissions_total_data( ‘withdrawable’ );16451646 $count = 0; // varible for counting 5 transaction details1647 foreach ($transaction_details as $transaction_id => $details) {1648 $count++;1649 if ($count <= 5) {1650 //$transaction_display_array[$transaction_id] = $details[‘total_amount’];1651 //$transaction_display_array[‘id’] = $transaction_id;1652 $transaction_display_array[$transaction_id][‘transaction_date’] = wcmp_date($details[‘post_date’]);1653 $transaction_display_array[$transaction_id][‘total_amount’] = $details[‘total_amount’];1654 }16551656 $total_amount = $total_amount + $details[‘total_amount’];1657 }1658 $WCMp->template->get_template('vendor-dashboard/dashboard-widgets/wcmp_vendor_transaction_details.php’, apply_filters( 'wcmp_widget_vendor_transaction_details_data’, array(‘total_amount’ => $unpaid_commission_total[‘total’], ‘transaction_display_array’ => $transaction_display_array), $vendor, $requestData ) );1659 }16601661 public function wcmp_vendor_products_cust_qna() {1662 global $WCMp;1663 $WCMp->template->get_template(‘vendor-dashboard/dashboard-widgets/wcmp_vendor_products_cust_qna.php’);1664 }16651666 public function wcmp_vendor_visitors_map() {1667 global $WCMp;1668 $WCMp->library->load_jqvmap_script_lib();1669 $vendor = get_current_vendor();1670 $visitor_map_stats = get_wcmp_vendor_dashboard_visitor_stats_data($vendor->id);1671 $visitor_map_stats[‘init’] = array(‘map’ => 'world_en’, ‘background_color’ => false, ‘color’ => '#a0a0a0’, ‘hover_color’ => false, ‘hover_opacity’ => 0.7);1672 //wp_enqueue_script('wcmp_gchart_loader’, ‘//www.gstatic.com/charts/loader.js’);1673 wp_enqueue_script('wcmp_visitor_map_data’, $WCMp->plugin_url . 'assets/frontend/js/wcmp_vendor_map_widget_data.js’, apply_filters('wcmp_vendor_visitors_map_script_dependancies’, array('jquery’, ‘wcmp-vmap-world-script’)));1674 wp_localize_script('wcmp_visitor_map_data’, 'visitor_map_stats’, apply_filters('wcmp_vendor_visitors_map_script_data’, $visitor_map_stats));1675 $WCMp->template->get_template(‘vendor-dashboard/dashboard-widgets/wcmp_vendor_visitors_map.php’);1676 }16771678 public function wcmp_dashboard_setup_updater() {1679 global $WCMp;1680 $has_updated_store_addresses = get_user_meta(get_current_user_id(), '_vendor_store_country_state_updated’, true);1681 $has_rejected_store_updater = get_user_meta(get_current_user_id(), '_vendor_rejected_store_country_state_update’, true);1682 $has_country = get_user_meta(get_current_user_id(), '_vendor_country’, true);1683 $has_country_code = get_user_meta(get_current_user_id(), '_vendor_country_code’, true);1684 if ($has_country && !$has_country_code && !$has_updated_store_addresses && !$has_rejected_store_updater && !$WCMp->endpoints->get_current_endpoint()) {1685 ?>1686 <div class="modal fade” id="vendor-setuo-updater-info-modal” role="dialog" data-backdrop="static" data-keyboard="false" aria-hidden="true">1687 <div class="modal-dialog">1688 <!-- Modal content–>1689 <div class="modal-content">1690 <form method="post">1691 <div class="modal-header">1692 <h4 class="modal-title"><?php _e(“Update your store country and state.", ‘dc-woocommerce-multi-vendor’); ?></h4>1693 </div>1694 <div class="modal-body">1695 <?php wp_nonce_field(‘wcmp-vendor-store-updater’); ?>1696 <div class="form-group">1697 <label><?php _e('Store Country’, ‘dc-woocommerce-multi-vendor’); ?></label>1698 <select name="vendor_country” id="vendor_country" class="country_to_state user-profile-fields form-control inp-btm-margin regular-select" rel="vendor_country">1699 <option value=""><?php _e('Select a country…’, ‘dc-woocommerce-multi-vendor’); ?></option>1700 <?php1701 $country_code = get_user_meta(get_current_user_id(), '_vendor_country_code’, true);1702 foreach (WC()->countries->get_allowed_countries() as $key => $value) {1703 echo ‘<option value="’ . esc_attr($key) . ‘"’ . selected(esc_attr($country_code), esc_attr($key), false) . ‘>’ . esc_html($value) . '</option>’;1704 }1705 ?>1706 </select>1707 </div>1708 <div class="form-group">1709 <label><?php _e('Store state’, ‘dc-woocommerce-multi-vendor’); ?></label>1710 <?php1711 $country_code = get_user_meta(get_current_user_id(), '_vendor_country_code’, true);1712 $states = WC()->countries->get_states($country_code);1713 ?>1714 <select name="vendor_state" id="vendor_state" class="state_select user-profile-fields form-control inp-btm-margin regular-select" rel="vendor_state">1715 <option value=""><?php esc_html_e('Select a state…’, ‘dc-woocommerce-multi-vendor’); ?></option>1716 <?php1717 $state_code = get_user_meta(get_current_user_id(), '_vendor_state_code’, true);1718 if ($states):1719 foreach ($states as $ckey => $cvalue) {1720 echo ‘<option value="’ . esc_attr($ckey) . '" ' . selected($state_code, $ckey, false) . ‘>’ . esc_html($cvalue) . '</option>’;1721 }1722 endif;1723 ?>1724 </select>1725 </div>1726 </div>1727 <div class="modal-footer">1728 <input type="submit" class="update btn btn-default" name="do_update_store_address" value="<?php _e(“Update", ‘dc-woocommerce-multi-vendor’); ?>"/>1729 <input type="submit” class="skip btn btn-secondary" name="do_reject_store_updater" value="<?php _e(“Skip", ‘dc-woocommerce-multi-vendor’); ?>"/>1730 </div>1731 </form>1732 </div>1733 </div>1734 </div>1735 <script type="text/javascript">1736 jQuery(document).ready(function ($) {1737 //this remove the close button on top if you need1738 $(‘#vendor-setuo-updater-info-modal’).find(‘.close’).remove();1739 //this unbind the event click on the shadow zone1740 $(‘#vendor-setuo-updater-info-modal’).unbind(‘click’);1741 $(“#vendor-setuo-updater-info-modal”).modal(‘show’);1742 });1743 </script>1744 <?php1745 }1746 }17471748 public function vendor_updater_handler() {1749 $wpnonce = isset($_REQUEST[‘_wpnonce’]) ? $_REQUEST[‘_wpnonce’] : '’;1750 if ($wpnonce && wp_verify_nonce($wpnonce, ‘wcmp-vendor-store-updater’)) {1751 $do_update = filter_input(INPUT_POST, ‘do_update_store_address’);1752 $do_skip = filter_input(INPUT_POST, ‘do_reject_store_updater’);1753 $country_code = filter_input(INPUT_POST, ‘vendor_country’);1754 $state_code = filter_input(INPUT_POST, ‘vendor_state’);17551756 if ($do_update) {1757 $country_data = WC()->countries->get_countries();1758 $state_data = WC()->countries->get_states($country_code);1759 $country_name = ( isset($country_data[$country_code]) ) ? $country_data[$country_code] : $country_code; //To get country name by code1760 $state_name = ( isset($state_data[$state_code]) ) ? $state_data[$state_code] : $state_code; //to get State name by state code17611762 update_user_meta(get_current_user_id(), '_vendor_country’, $country_name);1763 update_user_meta(get_current_user_id(), '_vendor_country_code’, $country_code);1764 update_user_meta(get_current_user_id(), '_vendor_state’, $state_name);1765 update_user_meta(get_current_user_id(), '_vendor_state_code’, $state_code);1766 update_user_meta(get_current_user_id(), '_vendor_store_country_state_updated’, true);1767 } elseif ($do_skip) {1768 update_user_meta(get_current_user_id(), '_vendor_rejected_store_country_state_update’, true);1769 }1770 wp_redirect(esc_url_raw(get_permalink(wcmp_vendor_dashboard_page_id())));1771 die();1772 }1773 }1774 1775 /**1776 * Save product1777 * @ since version 3.2.31778 */1779 public function save_product() {1780 global $WCMp;1781 if ( $_SERVER[‘REQUEST_METHOD’] === ‘POST’ ) { 1782 $current_endpoint_key = $WCMp->endpoints->get_current_endpoint();1783 // retrive the actual endpoint name in case admn changes that from settings1784 $current_endpoint = get_wcmp_vendor_settings( ‘wcmp_’ . str_replace( '-', '_’, $current_endpoint_key ) . '_endpoint’, 'vendor’, 'general’, $current_endpoint_key );1785 // retrive edit-product endpoint name in case admn changes that from settings1786 $edit_product_endpoint = get_wcmp_vendor_settings( 'wcmp_edit_product_endpoint’, 'vendor’, 'general’, ‘edit-product’ );1787 //Return if not edit product endpoint1788 if ( $current_endpoint !== $edit_product_endpoint || ! isset( $_POST[‘wcmp_product_nonce’] ) ) {1789 return;1790 }1791 1792 $vendor_id = get_current_user_id();17931794 if ( !is_user_wcmp_vendor($vendor_id) || ! current_user_can( ‘edit_products’ ) || empty( $_POST[‘post_ID’] ) || ! wp_verify_nonce( $_POST[‘wcmp_product_nonce’], ‘wcmp-product’ ) ) {1795 wp_die( -1 );1796 }1797 $errors = array();1798 $product_id = intval( $_POST[‘post_ID’] );1799 $post_object = get_post( $product_id );1800 $product = wc_get_product( $product_id );18011802 if ( ! $product->get_id() || ! $post_object || ‘product’ !== $post_object->post_type ) {1803 wp_die( __( 'Invalid product.’, ‘woocommerce’ ) );1804 }18051806 if ( ! $product->get_date_created( ‘edit’ ) ) {1807 $product->set_date_created( current_time( 'timestamp’, true ) );1808 }18091810 $title = ( ( is_product_wcmp_spmv($product_id) && isset( $_POST[‘original_post_title’] ) ) ? wc_clean( $_POST[‘original_post_title’] ) : isset( $_POST[‘post_title’] ) ) ? wc_clean( $_POST[‘post_title’] ) : '’;18111812 if ( isset( $_POST[‘status’] ) && $_POST[‘status’] === ‘draft’ ) {1813 $status = 'draft’;1814 } elseif ( isset( $_POST[‘status’] ) && $_POST[‘status’] === ‘publish’ ) {1815 if ( ! current_user_can( ‘publish_products’ ) ) {1816 $status = 'pending’;1817 } else {1818 $status = 'publish’;1819 }1820 } else {1821 wp_die( __( 'Invalid product status.’, ‘dc-woocommerce-multi-vendor’ ) );1822 }18231824 $post_data = apply_filters( 'wcmp_submitted_product_data’, array(1825 ‘ID’ => $product_id,1826 ‘post_title’ => $title,1827 ‘post_content’ => stripslashes( html_entity_decode( $_POST[‘product_description’], ENT_QUOTES, get_bloginfo( ‘charset’ ) ) ),1828 ‘post_excerpt’ => stripslashes( html_entity_decode( $_POST[‘product_excerpt’], ENT_QUOTES, get_bloginfo( ‘charset’ ) ) ),1829 ‘post_status’ => $status,1830 ‘post_type’ => 'product’,1831 ‘post_author’ => $vendor_id,1832 ‘post_date’ => gmdate( 'Y-m-d H:i:s’, $product->get_date_created( ‘edit’ )->getOffsetTimestamp() ),1833 ‘post_date_gmt’ => gmdate( 'Y-m-d H:i:s’, $product->get_date_created( ‘edit’ )->getTimestamp() ),1834 ), $_POST );18351836 do_action( ‘wcmp_before_post_update’ );18371838 $post_id = wp_update_post( $post_data, true );18391840 if ( $post_id && ! is_wp_error( $post_id ) ) {18411842 // Set Product Featured Image1843 $featured_img = ! empty( $_POST[‘featured_img’] ) ? wc_clean( absint( $_POST[‘featured_img’] ) ) : '’;1844 if ( $featured_img ) {1845 set_post_thumbnail( $post_id, $featured_img );1846 } else {1847 delete_post_thumbnail( $post_id );1848 }18491850 // Set Product Image Gallery1851 $attachment_ids = isset( $_POST[‘product_image_gallery’] ) ? explode( ',’, wc_clean( $_POST[‘product_image_gallery’] ) ) : array();18521853 $attachment_ids = array_filter( $attachment_ids, function( $attachment_id ) {1854 //image validity check1855 $attachment = wp_get_attachment_image( $attachment_id );1856 return ! empty( $attachment );1857 } );18581859 update_post_meta( $post_id, '_product_image_gallery’, implode( ',’, $attachment_ids ) );18601861 //remove dismiss meta if exists1862 if( get_post_meta($post_id, '_dismiss_to_do_list’, true) ) 1863 delete_post_meta($post_id, ‘_dismiss_to_do_list’);18641865 // Policy tab data save1866 if ( get_wcmp_vendor_settings( 'is_policy_on’, ‘general’ ) == ‘Enable’ && apply_filters( 'wcmp_vendor_can_overwrite_policies’, true ) ) {1867 if ( apply_filters( 'can_vendor_edit_shipping_policy_field’, true ) && isset( $_POST[‘_wcmp_shipping_policy’] ) ) {1868 update_post_meta( $post_id, '_wcmp_shipping_policy’, stripslashes( html_entity_decode( $_POST[‘_wcmp_shipping_policy’], ENT_QUOTES, get_bloginfo( ‘charset’ ) ) ) );1869 }1870 if ( apply_filters( 'can_vendor_edit_refund_policy_field’, true ) && isset( $_POST[‘_wcmp_refund_policy’] ) ) {1871 update_post_meta( $post_id, '_wcmp_refund_policy’, stripslashes( html_entity_decode( $_POST[‘_wcmp_refund_policy’], ENT_QUOTES, get_bloginfo( ‘charset’ ) ) ) );1872 }1873 if ( apply_filters( 'can_vendor_edit_cancellation_policy_field’, true ) && isset( $_POST[‘_wcmp_cancallation_policy’] ) ) {1874 update_post_meta( $post_id, '_wcmp_cancallation_policy’, stripslashes( html_entity_decode( $_POST[‘_wcmp_cancallation_policy’], ENT_QUOTES, get_bloginfo( ‘charset’ ) ) ) );1875 }1876 }1877 1878 // Process product type first so we have the correct class to run setters.1879 $product_type = empty( $_POST[‘product-type’] ) ? WC_Product_Factory::get_product_type( $post_id ) : sanitize_title( stripslashes( $_POST[‘product-type’] ) );18801881 wp_set_object_terms( $post_id, $product_type, ‘product_type’ );18821883 // Set Product Catagories1884 $catagories = isset( $_POST[‘tax_input’][‘product_cat’] ) ? array_filter( array_map( 'intval’, (array) $_POST[‘tax_input’][‘product_cat’] ) ) : array();1885 wp_set_object_terms( $post_id, $catagories, ‘product_cat’ );1886 // if product has different multi level categories hierarchy, save the default1887 if( isset( $_POST[‘_default_cat_hierarchy_term_id’] ) && in_array( $_POST[‘_default_cat_hierarchy_term_id’], $catagories ) && get_wcmp_vendor_settings('is_disable_marketplace_plisting’, ‘general’) != ‘Enable’ ){1888 update_post_meta( $post_id, '_default_cat_hierarchy_term_id’, absint( $_POST[‘_default_cat_hierarchy_term_id’] ) );1889 }else{1890 delete_post_meta( $post_id, ‘_default_cat_hierarchy_term_id’ );1891 }1892 // Set Product Tags1893 $tags = isset( $_POST[‘tax_input’][‘product_tag’] ) ? wp_parse_id_list( $_POST[‘tax_input’][‘product_tag’] ) : array();1894 wp_set_object_terms( $post_id, $tags, ‘product_tag’ );18951896 $custom_terms = isset( $_POST[‘tax_input’] ) ? array_diff_key( $_POST[‘tax_input’], array_flip( array( 'product_cat’, ‘product_tag’ ) ) ) : array();1897 // Set Product Custom Terms1898 if ( ! empty( $custom_terms ) ) {1899 foreach ( $custom_terms as $term => $value ) {1900 $custom_term = isset( $_POST[‘tax_input’][$term] ) ? array_filter( array_map( 'intval’, (array) $_POST[‘tax_input’][$term] ) ) : array();1901 wp_set_object_terms( $post_id, $custom_term, $term );1902 }1903 }1904 1905 // Set Product GTIN1906 if( isset( $_POST[‘_wcmp_gtin_type’] ) && !empty( $_POST[‘_wcmp_gtin_type’] ) ){1907 $term = get_term( $_POST[‘_wcmp_gtin_type’], $WCMp->taxonomy->wcmp_gtin_taxonomy );1908 if ($term && !is_wp_error( $term )) {1909 wp_delete_object_term_relationships( $post_id, $WCMp->taxonomy->wcmp_gtin_taxonomy );1910 wp_set_object_terms( $post_id, $term->term_id, $WCMp->taxonomy->wcmp_gtin_taxonomy, true );1911 }1912 }1913 if ( isset( $_POST[‘_wcmp_gtin_code’] ) ) {1914 update_post_meta( $post_id, '_wcmp_gtin_code’, wc_clean( wp_unslash( $_POST[‘_wcmp_gtin_code’] ) ) );1915 }19161917 //get the correct class1918 $classname = WC_Product_Factory::get_product_classname( $post_id, $product_type ? $product_type : ‘simple’ );1919 $product = new $classname( $post_id );1920 $attributes = isset( $_POST[‘wc_attributes’] ) ? wcmp_woo()->prepare_attributes( $_POST[‘wc_attributes’] ) : array();1921 $stock = null;1922 // Handle stock changes.1923 if ( isset( $_POST[‘_stock’] ) ) {1924 if ( isset( $_POST[‘_original_stock’] ) && wc_stock_amount( $product->get_stock_quantity( ‘edit’ ) ) !== wc_stock_amount( $_POST[‘_original_stock’] ) ) {1925 $error_msg = sprintf( __( 'The stock has not been updated because the value has changed since editing. Product %1$d has %2$d units in stock.’, ‘woocommerce’ ), $product->get_id(), $product->get_stock_quantity( ‘edit’ ) );1926 $errors[] = $error_msg;1927 } else {1928 $stock = wc_stock_amount( $_POST[‘_stock’] );1929 }1930 }1931 // Group Products1932 $grouped_products = isset( $_POST[‘grouped_products’] ) ? array_filter( array_map( 'intval’, (array) $_POST[‘grouped_products’] ) ) : array();19331934 // file paths will be stored in an array keyed off md5(file path)1935 $downloads = array();1936 if ( isset( $_POST[‘_downloadable’] ) && isset( $_POST[‘_wc_file_urls’] ) ) {1937 $file_urls = $_POST[‘_wc_file_urls’];1938 $file_names = isset( $_POST[‘_wc_file_names’] ) ? $_POST[‘_wc_file_names’] : array();1939 $file_hashes = isset( $_POST[‘_wc_file_hashes’] ) ? $_POST[‘_wc_file_hashes’] : array();19401941 $file_url_size = sizeof( $file_urls );1942 for ( $i = 0; $i < $file_url_size; $i ++ ) {1943 if ( ! empty( $file_urls[$i] ) ) {1944 $downloads[] = array(1945 ‘name’ => wc_clean( $file_names[$i] ),1946 ‘file’ => wp_unslash( trim( $file_urls[$i] ) ),1947 ‘download_id’ => wc_clean( $file_hashes[$i] ),1948 );1949 }1950 }1951 }19521953 $error = $product->set_props(1954 array(1955 ‘virtual’ => isset( $_POST[‘_virtual’] ),1956 ‘downloadable’ => isset( $_POST[‘_downloadable’] ),1957 ‘featured’ => isset( $_POST[‘_featured’] ),1958 ‘catalog_visibility’ => wc_clean( wp_unslash( $_POST[‘_visibility’] ) ),1959 ‘product_url’ => isset( $_POST[‘_product_url’] ) ? esc_url_raw( $_POST[‘_product_url’] ) : null,1960 ‘button_text’ => isset( $_POST[‘_button_text’] ) ? wc_clean( $_POST[‘_button_text’] ) : null,1961 ‘children’ => ‘grouped’ === $product_type ? $grouped_products : null,1962 ‘regular_price’ => isset( $_POST[‘_regular_price’] ) ? wc_clean( $_POST[‘_regular_price’] ) : null,1963 ‘sale_price’ => isset( $_POST[‘_sale_price’] ) ? wc_clean( $_POST[‘_sale_price’] ) : null,1964 ‘date_on_sale_from’ => isset( $_POST[‘_sale_price_dates_from’] ) ? wc_clean( $_POST[‘_sale_price_dates_from’] ) : null,1965 ‘date_on_sale_to’ => isset( $_POST[‘_sale_price_dates_to’] ) ? wc_clean( $_POST[‘_sale_price_dates_to’] ) : null,1966 ‘download_limit’ => empty( $_POST[‘_download_limit’] ) ? ‘’ : absint( $_POST[‘_download_limit’] ),1967 ‘download_expiry’ => empty( $_POST[‘_download_expiry’] ) ? ‘’ : absint( $_POST[‘_download_expiry’] ),1968 ‘downloads’ => $downloads,1969 ‘tax_status’ => isset( $_POST[‘_tax_status’] ) ? wc_clean( $_POST[‘_tax_status’] ) : null,1970 ‘tax_class’ => isset( $_POST[‘_tax_class’] ) ? wc_clean( $_POST[‘_tax_class’] ) : null,1971 ‘sku’ => isset( $_POST[‘_sku’] ) ? wc_clean( $_POST[‘_sku’] ) : null,1972 ‘manage_stock’ => ! empty( $_POST[‘_manage_stock’] ),1973 ‘stock_quantity’ => $stock,1974 ‘low_stock_amount’ => isset( $_POST[‘_low_stock_amount’] ) && ‘’ !== $_POST[‘_low_stock_amount’] ? wc_stock_amount( wp_unslash( $_POST[‘_low_stock_amount’] ) ) : '’,1975 ‘backorders’ => isset( $_POST[‘_backorders’] ) ? wc_clean( $_POST[‘_backorders’] ) : null,1976 ‘stock_status’ => isset( $_POST[‘_stock_status’] ) ? wc_clean( $_POST[‘_stock_status’] ) : null,1977 ‘sold_individually’ => ! empty( $_POST[‘_sold_individually’] ),1978 ‘weight’ => isset( $_POST[‘_weight’] ) ? wc_clean( $_POST[‘_weight’] ) : null,1979 ‘length’ => isset( $_POST[‘_length’] ) ? wc_clean( $_POST[‘_length’] ) : null,1980 ‘width’ => isset( $_POST[‘_width’] ) ? wc_clean( $_POST[‘_width’] ) : null,1981 ‘height’ => isset( $_POST[‘_height’] ) ? wc_clean( $_POST[‘_height’] ) : null,1982 ‘shipping_class_id’ => isset( $_POST[‘product_shipping_class’] ) ? absint( $_POST[‘product_shipping_class’] ) : null,1983 ‘upsell_ids’ => isset( $_POST[‘upsell_ids’] ) ? array_map( 'intval’, (array) $_POST[‘upsell_ids’] ) : array(),1984 ‘cross_sell_ids’ => isset( $_POST[‘crosssell_ids’] ) ? array_map( 'intval’, (array) $_POST[‘crosssell_ids’] ) : array(),1985 ‘purchase_note’ => isset( $_POST[‘_purchase_note’] ) ? wp_kses_post( stripslashes( $_POST[‘_purchase_note’] ) ) : null,1986 ‘menu_order’ => isset( $_POST[‘menu_order’] ) ? wc_clean( $_POST[‘menu_order’] ) : null,1987 ‘reviews_allowed’ => ! empty( $_POST[‘comment_status’] ) && ‘open’ === $_POST[‘comment_status’],1988 ‘attributes’ => $attributes,1989 ‘default_attributes’ => wcmp_woo()->prepare_set_attributes( $attributes, 'default_attribute_’, $_POST ),1990 )1991 );19921993 if ( is_wp_error( $error ) ) {1994 $errors[] = $error->get_error_message();1995 }19961997 do_action( 'wcmp_process_product_object’, $product, $_POST );19981999 $product->save();20002001 if ( $product->is_type( ‘variable’ ) ) {2002 $product->get_data_store()->sync_variation_names( $product, wc_clean( $_POST[‘original_post_title’] ), wc_clean( $_POST[‘post_title’] ) );2003 $error = wcmp_woo()->save_product_variations( $post_id, $_POST );2004 $errors = array_merge( $errors, $error );2005 }20062007 // Notify Admin on New Product Creation2008 if ( ( ! $_POST[‘is_update’] || $_POST[‘original_post_status’] == ‘draft’ ) && $status != ‘draft’ ) {2009 $WCMp->product->on_all_status_transitions( $status, '’, get_post( $post_id ) );2010 }20112012 do_action( ‘wcmp_process_product_meta_’ . $product_type, $post_id, $_POST );20132014 foreach ( $errors as $error ) {2015 wc_add_notice( $error, ‘error’ );2016 }2017 $status_msg = '’;2018 switch ( $status ) {2019 case 'draft’: $status_msg = __( 'Product is successfully drafted’, ‘dc-woocommerce-multi-vendor’ );2020 break;2021 case 'pending’: $status_msg = __( 'Product is successfully submitted for review’, ‘dc-woocommerce-multi-vendor’ );2022 break;2023 case 'publish’: $status_msg = sprintf( __( 'Product updated and live. <a href="%s” target="_blank">View Product</a>’, ‘dc-woocommerce-multi-vendor’ ), esc_attr( get_permalink( $post_id ) ) );2024 break;2025 }2026 wc_add_notice( $status_msg, ‘success’ );2027 wp_redirect( apply_filters( 'wcmp_vendor_save_product_redirect_url’, wcmp_get_vendor_dashboard_endpoint_url( get_wcmp_vendor_settings( 'wcmp_edit_product_endpoint’, 'vendor’, 'general’, ‘edit-product’ ), $post_id ) ) );2028 exit;2029 } else {2030 $error_msg = ( $post_id->get_error_code() === ‘empty_content’ ) ? __( 'Content, title, and excerpt are empty.’, ‘dc-woocommerce-multi-vendor’ ) : $post_id->get_error_message();2031 wc_add_notice( $error_msg, ‘error’ );2032 }2033 }2034 }2035 2036 public function save_coupon() {2037 global $WCMp;2038 $current_endpoint_key = $WCMp->endpoints->get_current_endpoint();2039 // retrive the actual endpoint name in case admn changes that from settings2040 $current_endpoint = get_wcmp_vendor_settings( ‘wcmp_’ . str_replace( '-', '_’, $current_endpoint_key ) . '_endpoint’, 'vendor’, 'general’, $current_endpoint_key );2041 // retrive add-coupon endpoint name in case admn changes that from settings2042 $add_coupon_endpoint = get_wcmp_vendor_settings( 'wcmp_add_coupon_endpoint’, 'vendor’, 'general’, ‘add-coupon’ );2043 //Return if not add coupon endpoint2044 if ( $current_endpoint !== $add_coupon_endpoint || ! isset( $_POST[‘wcmp_afm_coupon_nonce’] ) ) {2045 return;2046 }20472048 $vendor_id = get_current_user_id();20492050 if ( ! $vendor_id || ! current_vendor_can( ‘edit_shop_coupon’ ) || empty( $_POST[‘post_ID’] ) || ! wp_verify_nonce( $_POST[‘wcmp_afm_coupon_nonce’], ‘wcmp-afm-coupon’ ) ) {2051 wp_die( -1 );2052 }20532054 if ( empty( $_POST[‘post_title’] ) ) {2055 wc_add_notice( __( “Coupon code can’t be empty.", ‘dc-woocommerce-multi-vendor’ ), ‘error’ );2056 return;2057 }2058 2059 $cpn_pro_supports = false;2060 $cpn_pro_supports = ( !isset( $_POST[‘product_ids’] ) || empty( $_POST[‘product_ids’] ) ) ? $cpn_pro_supports : true;2061 $cpn_pro_supports = ( !$cpn_pro_supports && ( !isset( $_POST[‘product_categories’] ) || empty( $_POST[‘product_categories’] ) ) ) ? $cpn_pro_supports : true;2062 if ( !$cpn_pro_supports ) {2063 wc_add_notice( __( 'Select atleast one product or category.’, ‘dc-woocommerce-multi-vendor’ ), ‘error’ );2064 return;2065 }20662067 $post_id = absint( $_POST[‘post_ID’] );2068 $post = get_post( $post_id );2069 $coupon = new WC_Coupon( $post_id );2070 // Check for dupe coupons.2071 $coupon_code = wc_format_coupon_code( $_POST[‘post_title’] );2072 $id_from_code = wc_get_coupon_id_by_code( $coupon_code, $post_id );20732074 if ( $id_from_code ) {2075 if ( is_current_vendor_coupon( $id_from_code ) ) {2076 wc_add_notice( __( 'Coupon code already exists - customers will use the latest coupon with this code.’, ‘woocommerce’ ), ‘error’ );2077 } else {2078 wc_add_notice( __( 'Coupon code already exists - provide a different coupon code.’, ‘dc-woocommerce-multi-vendor’ ), ‘error’ );2079 return;2080 }2081 }20822083 if ( isset( $_POST[‘status’] ) && $_POST[‘status’] === ‘draft’ ) {2084 $status = 'draft’;2085 } elseif ( isset( $_POST[‘status’] ) && $_POST[‘status’] === ‘publish’ ) {2086 if ( ! current_vendor_can( ‘publish_shop_coupons’ ) ) {2087 $status = 'pending’;2088 } else {2089 $status = 'publish’;2090 }2091 } else {2092 wp_die( __( 'Invalid coupon status.’, ‘dc-woocommerce-multi-vendor’ ) );2093 }20942095 if ( ! $coupon->get_date_created( ‘edit’ ) ) {2096 $coupon->set_date_created( current_time( 'timestamp’, true ) );2097 }20982099 $title = ( isset( $_POST[‘post_title’] ) ) ? wc_clean( $_POST[‘post_title’] ) : '’;21002101 $post_data = apply_filters( 'afm_submitted_coupon_data’, array(2102 ‘ID’ => $post_id,2103 ‘post_title’ => $title,2104 ‘post_excerpt’ => stripslashes( html_entity_decode( $_POST[‘coupon_description’], ENT_QUOTES, get_bloginfo( ‘charset’ ) ) ),2105 ‘post_status’ => $status,2106 ‘post_type’ => 'shop_coupon’,2107 ‘post_author’ => $vendor_id,2108 ‘post_date’ => gmdate( 'Y-m-d H:i:s’, $coupon->get_date_created( ‘edit’ )->getOffsetTimestamp() ),2109 ‘post_date_gmt’ => gmdate( 'Y-m-d H:i:s’, $coupon->get_date_created( ‘edit’ )->getTimestamp() ),2110 ), $_POST );21112112 do_action( ‘wcmp_afm_before_coupon_post_update’ );21132114 $post_id = wp_update_post( $post_data, true );21152116 if ( $post_id && ! is_wp_error( $post_id ) ) {2117 $product_categories = isset( $_POST[‘product_categories’] ) ? (array) $_POST[‘product_categories’] : array();2118 $exclude_product_categories = isset( $_POST[‘exclude_product_categories’] ) ? (array) $_POST[‘exclude_product_categories’] : array();21192120 $errors = array();2121 $coupon = new WC_Coupon( $post_id );2122 $error = $coupon->set_props(2123 array(2124 ‘code’ => $title,2125 ‘discount_type’ => wc_clean( $_POST[‘discount_type’] ),2126 ‘amount’ => wc_format_decimal( $_POST[‘coupon_amount’] ),2127 ‘date_expires’ => wc_clean( $_POST[‘expiry_date’] ),2128 ‘individual_use’ => isset( $_POST[‘individual_use’] ),2129 ‘product_ids’ => isset( $_POST[‘product_ids’] ) ? array_filter( array_map( 'intval’, (array) $_POST[‘product_ids’] ) ) : array(),2130 ‘excluded_product_ids’ => isset( $_POST[‘exclude_product_ids’] ) ? array_filter( array_map( 'intval’, (array) $_POST[‘exclude_product_ids’] ) ) : array(),2131 ‘usage_limit’ => absint( $_POST[‘usage_limit’] ),2132 ‘usage_limit_per_user’ => absint( $_POST[‘usage_limit_per_user’] ),2133 ‘limit_usage_to_x_items’ => absint( $_POST[‘limit_usage_to_x_items’] ),2134 ‘free_shipping’ => isset( $_POST[‘free_shipping’] ),2135 ‘product_categories’ => array_filter( array_map( 'intval’, $product_categories ) ),2136 ‘excluded_product_categories’ => array_filter( array_map( 'intval’, $exclude_product_categories ) ),2137 ‘exclude_sale_items’ => isset( $_POST[‘exclude_sale_items’] ),2138 ‘minimum_amount’ => wc_format_decimal( $_POST[‘minimum_amount’] ),2139 ‘maximum_amount’ => wc_format_decimal( $_POST[‘maximum_amount’] ),2140 ‘email_restrictions’ => array_filter( array_map( 'trim’, explode( ',’, wc_clean( $_POST[‘customer_email’] ) ) ) ),2141 )2142 );2143 if ( is_wp_error( $error ) ) {2144 $errors[] = $error->get_error_message();2145 }2146 $coupon->save();2147 do_action( 'wcmp_afm_coupon_options_save’, $post_id, $coupon );21482149 foreach ( $errors as $error ) {2150 wc_add_notice( $error, ‘error’ );2151 }2152 $status_msg = '’;2153 switch ( $status ) {2154 case 'draft’: $status_msg = __( 'Coupon is successfully drafted’, ‘dc-woocommerce-multi-vendor’ );2155 break;2156 case 'pending’: $status_msg = __( 'Coupon is successfully submitted for review’, ‘dc-woocommerce-multi-vendor’ );2157 break;2158 case 'publish’: $status_msg = __( 'Coupon updated and live.’, ‘dc-woocommerce-multi-vendor’ );2159 break;2160 }2161 wc_add_notice( $status_msg, ‘success’ );21622163 wp_redirect( apply_filters( 'wcmp_vendor_save_coupon_redirect_url’, wcmp_get_vendor_dashboard_endpoint_url( get_wcmp_vendor_settings( 'wcmp_add_coupon_endpoint’, 'vendor’, 'general’, ‘add-coupon’ ), $post_id ) ) );2164 exit;2165 } else {2166 wc_add_notice( $post_id->get_error_message(), ‘error’ );2167 }2168 }2169 2170 public function wcmp_vendor_dashboard_add_product_url( $url ) {2171 if( !get_wcmp_vendor_settings('is_singleproductmultiseller’, ‘general’) == ‘Enable’ && get_wcmp_vendor_settings('is_disable_marketplace_plisting’, ‘general’) == ‘Enable’ ){2172 return esc_url(wcmp_get_vendor_dashboard_endpoint_url(get_wcmp_vendor_settings('wcmp_edit_product_endpoint’, 'vendor’, 'general’, ‘edit-product’)));2173 }2174 return $url;2175 }2176 2177 public function vendor_setup_wizard(){2178 global $WCMp;2179 2180 if (filter_input(INPUT_GET, ‘page’) != ‘vendor-store-setup’ || !apply_filters('wcmp_vendor_store_setup_wizard_enabled’, true)) {2181 return;2182 }2183 if ( !is_user_wcmp_vendor( get_current_user_id() ) ) {2184 return;2185 }2186 2187 $this->steps = $this->vendor_setup_wizard_steps();2188 $current_step = filter_input(INPUT_GET, ‘step’);2189 $this->step = $current_step ? sanitize_key($current_step) : current(array_keys($this->steps));2190 $this->vendor = get_current_vendor();2191 2192 // skip setup2193 if (filter_input(INPUT_GET, ‘page’) == ‘vendor-store-setup’ && filter_input(INPUT_GET, ‘skip_setup’) ) { 2194 update_user_meta( $this->vendor->id, '_vendor_skipped_setup_wizard’, true );2195 wp_redirect( wcmp_get_vendor_dashboard_endpoint_url( ‘dashboard’ ) );2196 exit;2197 }2198 2199 $suffix = defined(‘SCRIPT_DEBUG’) && SCRIPT_DEBUG ? ‘’ : '.min’;2200 wp_register_script('jquery-blockui’, WC()->plugin_url() . ‘/assets/js/jquery-blockui/jquery.blockUI’ . $suffix . '.js’, array(‘jquery’), '2.70’, true);2201 wp_register_script( 'jquery-tiptip’, WC()->plugin_url() . ‘/assets/js/jquery-tiptip/jquery.tipTip’ . $suffix . '.js’, array( ‘jquery’ ), WC_VERSION, true );2202 wp_register_script( 'selectWoo’, WC()->plugin_url() . ‘/assets/js/selectWoo/selectWoo.full’ . $suffix . '.js’, array( ‘jquery’ ), ‘1.0.0’ );2203 wp_register_script('wc-enhanced-select’, WC()->plugin_url() . ‘/assets/js/admin/wc-enhanced-select’ . $suffix . '.js’, array('jquery’, ‘selectWoo’), WC_VERSION);2204 wp_localize_script('wc-enhanced-select’, 'wc_enhanced_select_params’, array(2205 ‘i18n_no_matches’ => _x('No matches found’, 'enhanced select’, ‘dc-woocommerce-multi-vendor’),2206 ‘i18n_ajax_error’ => _x('Loading failed’, 'enhanced select’, ‘dc-woocommerce-multi-vendor’),2207 ‘i18n_input_too_short_1’ => _x('Please enter 1 or more characters’, 'enhanced select’, ‘dc-woocommerce-multi-vendor’),2208 ‘i18n_input_too_short_n’ => _x('Please enter %qty% or more characters’, 'enhanced select’, ‘dc-woocommerce-multi-vendor’),2209 ‘i18n_input_too_long_1’ => _x('Please delete 1 character’, 'enhanced select’, ‘dc-woocommerce-multi-vendor’),2210 ‘i18n_input_too_long_n’ => _x('Please delete %qty% characters’, 'enhanced select’, ‘dc-woocommerce-multi-vendor’),2211 ‘i18n_selection_too_long_1’ => _x('You can only select 1 item’, 'enhanced select’, ‘dc-woocommerce-multi-vendor’),2212 ‘i18n_selection_too_long_n’ => _x('You can only select %qty% items’, 'enhanced select’, ‘dc-woocommerce-multi-vendor’),2213 ‘i18n_load_more’ => _x('Loading more results…’, 'enhanced select’, ‘dc-woocommerce-multi-vendor’),2214 ‘i18n_searching’ => _x('Searching…’, 'enhanced select’, ‘dc-woocommerce-multi-vendor’),2215 ‘ajax_url’ => admin_url(‘admin-ajax.php’),2216 ‘search_products_nonce’ => wp_create_nonce(‘search-products’),2217 ‘search_customers_nonce’ => wp_create_nonce(‘search-customers’),2218 ));22192220 wp_enqueue_style('woocommerce_admin_styles’, WC()->plugin_url() . '/assets/css/admin.css’, array(), WC_VERSION);2221 wp_enqueue_style('wc-setup’, WC()->plugin_url() . '/assets/css/wc-setup.css’, array('dashicons’, ‘install’), WC_VERSION);2222 wp_register_script('wc-setup’, WC()->plugin_url() . ‘/assets/js/admin/wc-setup’ . $suffix . '.js’, array('jquery’, 'wc-enhanced-select’, 'jquery-blockui’, ‘jquery-tiptip’), WC_VERSION);2223 wp_register_script('wcmp-setup’, $WCMp->plugin_url . '/assets/admin/js/setup-wizard.js’, array(‘wc-setup’), WC_VERSION);2224 wp_localize_script('wc-setup’, 'wc_setup_params’, array(2225 ‘locale_info’ => json_encode(include( WC()->plugin_path() . ‘/i18n/locale-info.php’ )),2226 ‘states’ => WC()->countries->get_states(),2227 ));2228 2229 if (!empty($_POST[‘save_step’]) && isset($this->steps[$this->step][‘handler’])) {2230 call_user_func($this->steps[$this->step][‘handler’], $this);2231 }2232 2233 ob_start();2234 $this->setup_wizard_header();2235 $this->setup_wizard_steps();2236 $this->setup_wizard_content();2237 $this->setup_wizard_footer();2238 exit();2239 }2240 2241 /**2242 * Get the URL for the next step’s screen.2243 * @param string step slug (default: current step)2244 * @return string URL for next step if a next step exists.2245 * Admin URL if it’s the last step.2246 * Empty string on failure.2247 * @since 2.7.72248 */2249 public function get_next_step_link($step = ‘’) {2250 if (!$step) {2251 $step = $this->step;2252 }22532254 $keys = array_keys($this->steps);2255 if (end($keys) === $step) {2256 return admin_url();2257 }22582259 $step_index = array_search($step, $keys);2260 if (false === $step_index) {2261 return '’;2262 }22632264 return add_query_arg('step’, $keys[$step_index + 1]);2265 }2266 2267 public function vendor_setup_wizard_steps(){2268 $default_steps = array(2269 ‘introduction’ => array(2270 ‘name’ => __('Introduction’, ‘dc-woocommerce-multi-vendor’),2271 ‘view’ => array($this, ‘vendor_setup_introduction’),2272 ‘handler’ => '’,2273 ),2274 ‘store_setup’ => array(2275 ‘name’ => __('Store setup’, ‘dc-woocommerce-multi-vendor’),2276 ‘view’ => array($this, ‘vendor_store_setup’),2277 ‘handler’ => array( $this, ‘wcmp_setup_store_setup_save’ ),2278 ),2279 ‘payment’ => array(2280 ‘name’ => __( 'Payment’, ‘woocommerce’ ),2281 ‘view’ => array( $this, ‘vendor_payment_setup’ ),2282 ‘handler’ => array( $this, ‘wcmp_setup_payment_save’ ),2283 ),2284 ‘next_steps’ => array(2285 ‘name’ => __( 'Ready!’, ‘woocommerce’ ),2286 ‘view’ => array( $this, ‘wcmp_store_setup_ready’ ),2287 ‘handler’ => '’,2288 ),2289 );2290 return apply_filters('wcmp_vendor_setup_wizard_steps’, $default_steps);2291 }2292 2293 /**2294 * Setup Wizard Header.2295 */2296 public function setup_wizard_header() {2297 global $WCMp;2298 ?>2299 <!DOCTYPE html>2300 <html <?php language_attributes(); ?>>2301 <head>2302 <meta name="viewport” content="width=device-width" />2303 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />2304 <title>2305 <?php 2306 printf(2307 __( '%s › Store Setup Wizard’, ‘dc-woocommerce-multi-vendor’ ),2308 wp_specialchars_decode( get_option( ‘blogname’ ), ENT_QUOTES )2309 );2310 ?>2311 </title>2312 <?php wp_print_scripts(‘wc-setup’); ?>2313 <?php wp_print_scripts(‘wcmp-setup’); ?>2314 <?php do_action(‘admin_print_styles’); ?>2315 <?php do_action(‘wcmp_vendor_head’); ?>2316 <style type="text/css">2317 .wc-setup-steps {2318 justify-content: center;2319 }2320 </style>2321 </head>2322 <body class="wcmp-vendor-wizard wc-setup wp-core-ui">2323 <h1 id="wc-logo">2324 <a href="<?php echo apply_filters( 'wcmp_vendor_setup_wizard_site_logo_link’, site_url(), get_current_user_id() ); ?>">2325 <?php $site_logo = get_wcmp_vendor_settings('wcmp_dashboard_site_logo’, 'vendor’, ‘dashboard’) ? get_wcmp_vendor_settings('wcmp_dashboard_site_logo’, 'vendor’, ‘dashboard’) : '’;2326 if ($site_logo) { ?>2327 <img src="<?php echo get_url_from_upload_field_value($site_logo); ?>" alt="<?php echo bloginfo(); ?>">2328 <?php } else {2329 echo bloginfo();2330 } ?>2331 </a>2332 </h1>2333 <?php2334 }23352336 /**2337 * Output the steps.2338 */2339 public function setup_wizard_steps() {2340 $ouput_steps = $this->steps;2341 array_shift($ouput_steps);2342 ?>2343 <ol class="wc-setup-steps">2344 <?php foreach ($ouput_steps as $step_key => $step) : ?>2345 <li class="<?php2346 if ($step_key === $this->step) {2347 echo 'active’;2348 } elseif (array_search($this->step, array_keys($this->steps)) > array_search($step_key, array_keys($this->steps))) {2349 echo 'done’;2350 }2351 ?>"><?php echo esc_html($step[‘name’]); ?></li>2352 <?php endforeach; ?>2353 </ol>2354 <?php2355 }23562357 /**2358 * Output the content for the current step.2359 */2360 public function setup_wizard_content() {2361 echo '<div class="wc-setup-content">’;2362 call_user_func($this->steps[$this->step][‘view’], $this);2363 echo '</div>’;2364 }2365 2366 /**2367 * Setup Wizard Footer.2368 */2369 public function setup_wizard_footer() {2370 do_action( 'wcmp_vendor_setup_wizard_footer’, $this->step, $this->vendor );2371 ?>2372 </body>2373 </html>2374 <?php2375 }23762377 /**2378 * Introduction step.2379 */2380 public function vendor_setup_introduction() {2381 $setup_wizard_introduction = get_wcmp_vendor_settings(‘setup_wizard_introduction’);2382 if($setup_wizard_introduction){2383 echo htmlspecialchars_decode( wpautop( $setup_wizard_introduction ), ENT_QUOTES );2384 }else{2385 ?>2386 <h1><?php 2387 printf(2388 __( 'Welcome to the %s family!’, ‘dc-woocommerce-multi-vendor’ ),2389 wp_specialchars_decode( get_option( ‘blogname’ ), ENT_QUOTES )2390 );2391 ?></h1>2392 <p><?php _e('Thank you for being the part of us. This quick setup wizard will help you configure the basic store settings and you will have your marketplace ready in no time. <strong>It’s completely optional and shouldn’t take longer than five minutes.</strong>’, ‘dc-woocommerce-multi-vendor’); ?></p>2393 <p><?php esc_html_e(“If you don’t want to go through the wizard right now, you can skip and return to the dashboard. Come back anytime if you change your mind!", ‘dc-woocommerce-multi-vendor’); ?></p>2394 <?php } ?>2395 <p class="wc-setup-actions step">2396 <a href="<?php echo esc_url($this->get_next_step_link()); ?>” class="button-primary button button-large button-next"><?php esc_html_e(“Let’s go!", ‘dc-woocommerce-multi-vendor’); ?></a>2397 <a href="<?php echo wcmp_get_vendor_dashboard_endpoint_url( ‘dashboard’ ) . '?page=vendor-store-setup&skip_setup=1’; ?>” class="button button-large"><?php esc_html_e('Not right now’, ‘dc-woocommerce-multi-vendor’); ?></a>2398 </p>2399 <?php2400 }2401 2402 /**2403 * Store setup step.2404 */2405 public function vendor_store_setup() {2406 2407 $store_name = ( $this->vendor->page_title ) ? $this->vendor->page_title : '’;2408 $address = ( $this->vendor->address_1 ) ? $this->vendor->address_1 : WC()->countries->get_base_address();2409 $address_2 = ( $this->vendor->address_2 ) ? $this->vendor->address_2 : WC()->countries->get_base_address_2();2410 $city = ( $this->vendor->city ) ? $this->vendor->city : WC()->countries->get_base_city();2411 $state = ( $this->vendor->state_code ) ? $this->vendor->state_code : WC()->countries->get_base_state();2412 $country = ( $this->vendor->country_code ) ? $this->vendor->country_code : WC()->countries->get_base_country();2413 $postcode = ( $this->vendor->postcode ) ? $this->vendor->postcode : WC()->countries->get_base_postcode();2414 $store_phone = ( $this->vendor->phone ) ? $this->vendor->phone : '’;2415 if ( empty( $country ) ) {2416 $user_location = WC_Geolocation::geolocate_ip();2417 $country = $user_location[‘country’];2418 $state = $user_location[‘state’];2419 }2420 $locale_info = include WC()->plugin_path() . '/i18n/locale-info.php’;2421 $currency_by_country = wp_list_pluck( $locale_info, ‘currency_code’ );2422 $current_offset = get_user_meta($this->vendor->id, 'gmt_offset’, true);2423 $tzstring = get_user_meta($this->vendor->id, 'timezone_string’, true);2424 // Remove old Etc mappings. Fallback to gmt_offset.2425 if (false !== strpos($tzstring, ‘Etc/GMT’)) {2426 $tzstring = '’;2427 }24282429 if (empty($tzstring)) { // Create a UTC± zone if no timezone string exists2430 $check_zone_info = false;2431 if (0 == $current_offset) {2432 $tzstring = 'UTC+0’;2433 } elseif ($current_offset < 0) {2434 $tzstring = ‘UTC’ . $current_offset;2435 } else {2436 $tzstring = ‘UTC+’ . $current_offset;2437 }2438 }2439 ?>2440 <!–h1><?php esc_html_e('Store Setup’, ‘dc-woocommerce-multi-vendor’); ?></h1–>2441 <form method="post" class="store-address-info">2442 <?php wp_nonce_field( ‘wcmp-vendor-setup’ ); ?>2443 <p class="store-setup"><?php esc_html_e( 'The following wizard will help you configure your store and get you started quickly.’, ‘woocommerce’ ); ?></p>2444 2445 <div class="store-address-container">2446 2447 <label class="location-prompt" for="store_name"><?php esc_html_e('Store Name’, ‘dc-woocommerce-multi-vendor’); ?></label>2448 <input type="text" id="store_name" class="location-input" name="store_name" value="<?php echo esc_attr( $store_name ); ?>" placeholder="<?php _e('Enter your Store Name here’, ‘dc-woocommerce-multi-vendor’); ?>" />2449 2450 <label for="store_country" class="location-prompt"><?php esc_html_e( 'Where is your store based?’, ‘woocommerce’ ); ?></label>2451 <select id="store_country" name="store_country" data-placeholder="<?php esc_attr_e( 'Choose a country…’, ‘woocommerce’ ); ?>" aria-label="<?php esc_attr_e( 'Country’, ‘woocommerce’ ); ?>" class="location-input wc-enhanced-select dropdown">2452 <?php foreach ( WC()->countries->get_countries() as $code => $label ) : ?>2453 <option <?php selected( $code, $country ); ?> value="<?php echo esc_attr( $code ); ?>"><?php echo esc_html( $label ); ?></option>2454 <?php endforeach; ?>2455 </select>24562457 <label class="location-prompt" for="store_address_1"><?php esc_html_e( 'Address’, ‘woocommerce’ ); ?></label>2458 <input type="text" id="store_address_1" class="location-input" name="store_address_1" value="<?php echo esc_attr( $address ); ?>" />24592460 <label class="location-prompt" for="store_address_2"><?php esc_html_e( 'Address line 2’, ‘woocommerce’ ); ?></label>2461 <input type="text" id="store_address_2" class="location-input" name="store_address_2" value="<?php echo esc_attr( $address_2 ); ?>" />24622463 <div class="city-and-postcode">2464 <div>2465 <label class="location-prompt" for="store_city"><?php esc_html_e( 'City’, ‘woocommerce’ ); ?></label>2466 <input type="text" id="store_city" class="location-input" name="store_city" value="<?php echo esc_attr( $city ); ?>" />2467 </div>2468 <div class="store-state-container hidden">2469 <label for="store_state" class="location-prompt">2470 <?php esc_html_e( 'State’, ‘woocommerce’ ); ?>2471 </label>2472 <select id="store_state" name="store_state" data-placeholder="<?php esc_attr_e( 'Choose a state…’, ‘woocommerce’ ); ?>" aria-label="<?php esc_attr_e( 'State’, ‘woocommerce’ ); ?>" class="location-input wc-enhanced-select dropdown"></select>2473 </div>2474 <div>2475 <label class="location-prompt" for="store_postcode"><?php esc_html_e( 'Postcode / ZIP’, ‘woocommerce’ ); ?></label>2476 <input type="text" id="store_postcode" class="location-input" name="store_postcode" value="<?php echo esc_attr( $postcode ); ?>" />2477 </div>2478 </div>2479 <div class="city-and-postcode">2480 <div>2481 <label class="location-prompt" for="store_phone"><?php esc_html_e( 'Phone’, ‘dc-woocommerce-multi-vendor’ ); ?></label>2482 <input type="text" id="store_phone" class="location-input" name="store_phone" value="<?php echo esc_attr( $store_phone ); ?>" />2483 </div>2484 <div>2485 <label class="location-prompt" for="timezone_string"><?php esc_html_e( 'Timezone’, ‘dc-woocommerce-multi-vendor’ ); ?></label>2486 <select id="timezone_string" name="timezone_string" class="location-input wc-enhanced-select dropdown" aria-describedby="timezone-description">2487 <?php echo wp_timezone_choice($tzstring, get_user_locale()); ?>2488 </select>2489 </div>2490 </div>2491 </div>2492 <script type="text/javascript">2493 var wc_setup_currencies = JSON.parse( decodeURIComponent( ‘<?php echo rawurlencode( wp_json_encode( $currency_by_country ) ); ?>’ ) );2494 var wc_base_state = “<?php echo esc_js( $state ); ?>";2495 </script>2496 2497 <p class="wc-setup-actions step">2498 <input type="submit” class="button-primary button button-large button-next" value="<?php esc_attr_e('Continue’, ‘dc-woocommerce-multi-vendor’); ?>" name="save_step" />2499 <a href="<?php echo esc_url($this->get_next_step_link()); ?>" class="button button-large button-next"><?php esc_html_e('Skip this step’, ‘dc-woocommerce-multi-vendor’); ?></a>2500 </p>2501 </form>2502 <?php2503 }2504 2505 /**2506 * Save initial store settings.2507 */2508 public function wcmp_setup_store_setup_save(){2509 global $WCMp;2510 if ( ! isset( $_POST[‘_wpnonce’] ) || ! wp_verify_nonce( $_POST[‘_wpnonce’], ‘wcmp-vendor-setup’ ) ) return;25112512 $storename = isset( $_POST[‘store_name’] ) ? wc_clean( wp_unslash( $_POST[‘store_name’] ) ) : '’;2513 $address_1 = isset( $_POST[‘store_address_1’] ) ? wc_clean( wp_unslash( $_POST[‘store_address_1’] ) ) : '’;2514 $address_2 = isset( $_POST[‘store_address_2’] ) ? wc_clean( wp_unslash( $_POST[‘store_address_2’] ) ) : '’;2515 $city = isset( $_POST[‘store_city’] ) ? wc_clean( wp_unslash( $_POST[‘store_city’] ) ) : '’;2516 $country = isset( $_POST[‘store_country’] ) ? wc_clean( wp_unslash( $_POST[‘store_country’] ) ) : '’;2517 $state = isset( $_POST[‘store_state’] ) ? wc_clean( wp_unslash( $_POST[‘store_state’] ) ) : '’;2518 $postcode = isset( $_POST[‘store_postcode’] ) ? wc_clean( wp_unslash( $_POST[‘store_postcode’] ) ) : '’;2519 $storephone = isset( $_POST[‘store_phone’] ) ? wc_clean( wp_unslash( $_POST[‘store_phone’] ) ) : '’;2520 $tzstring = isset( $_POST[‘timezone_string’] ) ? wc_clean( wp_unslash( $_POST[‘timezone_string’] ) ) : '’;25212522 if ( $storename ) {2523 wp_update_term( $this->vendor->term_id, $WCMp->taxonomy->taxonomy_name, array(‘name’ => $storename) );2524 update_user_meta( $this->vendor->id, '_vendor_page_title’, $storename );2525 }2526 if ( $address_1 ) update_user_meta( $this->vendor->id, '_vendor_address_1’, $address_1 );2527 if ( $address_2 ) update_user_meta( $this->vendor->id, '_vendor_address_2’, $address_2 );2528 if ( $city ) update_user_meta( $this->vendor->id, '_vendor_city’, $city );2529 if( $country ) {2530 $country_code = $country;2531 $country_data = WC()->countries->get_countries();2532 $country_name = ( isset($country_data[$country_code]) ) ? $country_data[$country_code] : $country_code; //To get country name by code2533 update_user_meta( $this->vendor->id, '_vendor_country’, $country_name );2534 update_user_meta( $this->vendor->id, '_vendor_country_code’, $country_code );2535 }2536 if ( $state ) {2537 $country_code = $country;2538 $state_code = $state;2539 $state_data = WC()->countries->get_states($country_code);2540 $state_name = ( isset($state_data[$state_code]) ) ? $state_data[$state_code] : $state_code; //to get State name by state code2541 update_user_meta( $this->vendor->id, '_vendor_state’, $state_name );2542 update_user_meta( $this->vendor->id, '_vendor_state_code’, $state_code );2543 }2544 if ( $postcode ) update_user_meta( $this->vendor->id, '_vendor_postcode’, $postcode );2545 if ( $storephone ) update_user_meta( $this->vendor->id, '_vendor_phone’, $storephone );2546 if ( $tzstring ) {2547 if ( !empty( $tzstring ) && preg_match('/^UTC[±]/’, $tzstring ) ) {2548 $gmt_offset = $tzstring;2549 $gmt_offset = preg_replace( '/UTC\+?/’, '’, $gmt_offset );2550 $tzstring = '’;2551 } else {2552 $gmt_offset = 0;2553 }2554 update_user_meta( $this->vendor->id, 'timezone_string’, $tzstring );2555 update_user_meta( $this->vendor->id, 'gmt_offset’, $gmt_offset );2556 }2557 // set flag2558 update_user_meta( $this->vendor->id, '_vendor_is_completed_setup_wizard’, true );2559 wp_safe_redirect( esc_url_raw( $this->get_next_step_link() ) );2560 exit;2561 }2562 2563 /**2564 * Payment setup step.2565 */2566 public function vendor_payment_setup() { 2567 $vendor_payment_mode = ( $this->vendor->payment_mode ) ? $this->vendor->payment_mode : '’;2568 $available_gateways = apply_filters( 'wcmp_vendor_setup_wizard_available_payment_gateways’, get_wcmp_available_payment_gateways(), $this->vendor );2569 ?>2570 <h1><?php esc_html_e( 'Payment Method’, ‘dc-woocommerce-multi-vendor’ ); ?></h1>2571 <form method="post" class="wc-wizard-payment-gateway-form">2572 <?php wp_nonce_field( ‘wcmp-vendor-setup’ ); ?>2573 <p>2574 <?php2575 printf(2576 __( '%s offers the following payment methods for you.’, ‘dc-woocommerce-multi-vendor’ ),2577 wp_specialchars_decode( get_option( ‘blogname’ ), ENT_QUOTES )2578 );2579 ?>2580 </p>2581 2582 <div class="product-type-container">2583 <label class="location-prompt" for="product_type">2584 <?php esc_html_e( 'Choose Payment Method’, ‘dc-woocommerce-multi-vendor’ ); ?>2585 </label>2586 <select id="vendor_payment_mode" name="vendor_payment_mode" class="location-input wc-enhanced-select dropdown">2587 <?php2588 foreach ( $available_gateways as $gateway_id => $gateway ) { ?>2589 <option <?php selected( $gateway_id, $vendor_payment_mode ); ?> value="<?php echo esc_attr( $gateway_id ); ?>"><?php echo esc_html( $gateway ); ?></option>2590 <?php }2591 ?>2592 </select>2593 </div>2594 <p class="wc-setup-actions step">2595 <input type="submit" class="button-primary button button-large button-next" value="<?php esc_attr_e('Continue’, ‘dc-woocommerce-multi-vendor’); ?>" name="save_step" />2596 <a href="<?php echo esc_url($this->get_next_step_link()); ?>" class="button button-large button-next"><?php esc_html_e('Skip this step’, ‘dc-woocommerce-multi-vendor’); ?></a>2597 </p>2598 </form>2599 <?php2600 }2601 2602 /**2603 * Save initial payment settings.2604 */2605 public function wcmp_setup_payment_save(){2606 if ( ! isset( $_POST[‘_wpnonce’] ) || ! wp_verify_nonce( $_POST[‘_wpnonce’], ‘wcmp-vendor-setup’ ) ) return;26072608 $payment_mode = isset( $_POST[‘vendor_payment_mode’] ) ? wc_clean( wp_unslash( $_POST[‘vendor_payment_mode’] ) ) : '’;2609 if ( $payment_mode ) update_user_meta( $this->vendor->id, '_vendor_payment_mode’, $payment_mode );2610 wp_redirect( esc_url_raw( $this->get_next_step_link() ) );2611 exit;2612 }2613 2614 /**2615 * Final setup step.2616 */2617 public function wcmp_store_setup_ready() { 2618 ?>2619 <h1><?php esc_html_e( “You’re ready to start selling!", ‘woocommerce’ ); ?></h1>26202621 <ul class="wc-wizard-next-steps">2622 <li class="wc-wizard-next-step-item">2623 <div class="wc-wizard-next-step-description">2624 <p class="next-step-heading"><?php esc_html_e( 'Next step’, ‘woocommerce’ ); ?></p>2625 <h3 class="next-step-description"><?php esc_html_e( 'Create some products’, ‘woocommerce’ ); ?></h3>2626 <p class="next-step-extra-info"><?php esc_html_e( “You’re ready to add products to your store.", ‘woocommerce’ ); ?></p>2627 </div>2628 <div class="wc-wizard-next-step-action">2629 <p class="wc-setup-actions step">2630 <a class="button button-primary button-large” href="<?php echo apply_filters( 'wcmp_vendor_setup_wizard_ready_add_product_url’, wcmp_get_vendor_dashboard_endpoint_url( get_wcmp_vendor_settings( 'wcmp_add_product_endpoint’, 'vendor’, 'general’, ‘add-product’ ) ) ); ?>">2631 <?php esc_html_e( 'Create a product’, ‘woocommerce’ ); ?>2632 </a>2633 </p>2634 </div>2635 </li>2636 <li class="wc-wizard-additional-steps">2637 <div class="wc-wizard-next-step-description">2638 <p class="next-step-heading"><?php esc_html_e( 'You can also:’, ‘woocommerce’ ); ?></p>2639 </div>2640 <div class="wc-wizard-next-step-action">2641 <p class="wc-setup-actions step">2642 <a class="button button-large” href="<?php echo wcmp_get_vendor_dashboard_endpoint_url( ‘dashboard’ ); ?>">2643 <?php esc_html_e( 'Visit Dashboard’, ‘woocommerce’ ); ?>2644 </a>2645 <a class="button button-large" href="<?php echo wcmp_get_vendor_dashboard_endpoint_url( get_wcmp_vendor_settings( 'wcmp_vendor_billing_endpoint’, 'vendor’, 'general’, ‘vendor-billing’ ) ); ?>">2646 <?php esc_html_e( 'Payment Configure’, ‘dc-woocommerce-multi-vendor’ ); ?>2647 </a>2648 <a class="button button-large" href="<?php echo wcmp_get_vendor_dashboard_endpoint_url( get_wcmp_vendor_settings( 'wcmp_store_settings_endpoint’, 'vendor’, 'general’, ‘storefront’ ) ); ?>">2649 <?php esc_html_e( 'Store Customize’, ‘dc-woocommerce-multi-vendor’ ); ?>2650 </a>2651 </p>2652 </div>2653 </li>2654 </ul>2655 <?php2656 }26572658 public function save_handler_vendor_orders( $postdata ) {2659 global $wp;2660 if( $postdata ) {2661 $vendor_order_id = $wp->query_vars[get_wcmp_vendor_settings( 'wcmp_vendor_orders_endpoint’, 'vendor’, 'general’, ‘vendor-orders’ )];2662 if( isset( $postdata[‘update_cust_refund_status’] ) && $vendor_order_id ) {2663 if( isset( $postdata[‘refund_order_customer’] ) && $postdata[‘refund_order_customer’] ) {2664 update_post_meta( $vendor_order_id, '_customer_refund_order’, $postdata[‘refund_order_customer’] );2665 // trigger customer email2666 if( in_array( $postdata[‘refund_order_customer’], array( 'refund_reject’, ‘refund_accept’ ) ) ) {26672668 $refund_details = array(2669 ‘admin_reason’ => isset( $postdata[‘refund_admin_reason_text’] ) ? $postdata[‘refund_admin_reason_text’] : '’,2670 );26712672 $order_status = '’;2673 if( $_POST[‘refund_order_customer’] == ‘refund_accept’ ) {2674 $order_status = __( 'accepted’, ‘dc-woocommerce-multi-vendor’ );2675 }elseif( $_POST[‘refund_order_customer’] == ‘refund_reject’) {2676 $order_status = __( 'rejected’, ‘dc-woocommerce-multi-vendor’ );2677 }2678 // Comment note for suborder2679 $order = wc_get_order( $vendor_order_id );2680 $comment_id = $order->add_order_note( __(‘Vendor ‘.$order_status.’ refund request for order #’.$vendor_order_id.’ .’, ‘dc-woocommerce-multi-vendor’) );2681 // user info2682 $user_info = get_userdata(get_current_user_id());2683 wp_update_comment(array(‘comment_ID’ => $comment_id, ‘comment_author’ => $user_info->user_name, ‘comment_author_email’ => $user_info->user_email));26842685 // Comment note for parent order2686 $parent_order_id = wp_get_post_parent_id($vendor_order_id);2687 $parent_order = wc_get_order( $parent_order_id );2688 $comment_id_parent = $parent_order->add_order_note( __('Vendor ‘.$order_status.’ refund request for order #’.$vendor_order_id.’.’, ‘dc-woocommerce-multi-vendor’) );2689 wp_update_comment(array(‘comment_ID’ => $comment_id_parent, ‘comment_author’ => $user_info->user_name, ‘comment_author_email’ => $user_info->user_email));26902691 $mail = WC()->mailer()->emails[‘WC_Email_Customer_Refund_Request’];2692 $billing_email = get_post_meta( $vendor_order_id, '_billing_email’, true );2693 $mail->trigger( $billing_email, $vendor_order_id, $refund_details, ‘customer’ );2694 }2695 }2696 }2697 }2698 }26992700}

CVE: Latest News

CVE-2023-50976: Transactions API Authorization by oleiman · Pull Request #14969 · redpanda-data/redpanda
CVE-2023-6905
CVE-2023-6903
CVE-2023-6904
CVE-2023-3907