Changeset 3107443
- Timestamp:
- 06/25/2024 11:45:01 AM (22 months ago)
- Location:
- product-feeder
- Files:
-
- 11 added
- 3 edited
-
tags/2.5.0 (added)
-
tags/2.5.0/includes (added)
-
tags/2.5.0/includes/css (added)
-
tags/2.5.0/includes/css/product-feeder.css (added)
-
tags/2.5.0/includes/product-feeder.php (added)
-
tags/2.5.0/languages (added)
-
tags/2.5.0/languages/product-feeder-nl_NL.mo (added)
-
tags/2.5.0/languages/product-feeder-nl_NL.po (added)
-
tags/2.5.0/product-feeder.php (added)
-
tags/2.5.0/readme.txt (added)
-
tags/2.5.0/uninstall.php (added)
-
trunk/includes/product-feeder.php (modified) (3 diffs)
-
trunk/product-feeder.php (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
product-feeder/trunk/includes/product-feeder.php
r3105586 r3107443 138 138 } 139 139 global $wpdb; 140 $query = $wpdb->prepare("SELECT DISTINCT(`".$wpdb->postmeta."`.meta_key) FROM `".$wpdb->posts."` LEFT JOIN `".$wpdb->postmeta."` ON `".$wpdb->posts."`.ID = `".$wpdb->postmeta."`.post_id WHERE `".$wpdb->posts."`.post_type = '%s'AND `".$wpdb->postmeta."`.meta_key != '' AND `".$wpdb->postmeta."`.meta_key NOT RegExp '(^[_0-9].+$)'", 'product_variation');140 $query = $wpdb->prepare("SELECT DISTINCT(`".$wpdb->postmeta."`.meta_key) FROM `".$wpdb->posts."` LEFT JOIN `".$wpdb->postmeta."` ON `".$wpdb->posts."`.ID = `".$wpdb->postmeta."`.post_id WHERE `".$wpdb->posts."`.post_type = %s AND `".$wpdb->postmeta."`.meta_key != '' AND `".$wpdb->postmeta."`.meta_key NOT RegExp '(^[_0-9].+$)'", 'product_variation'); 141 141 foreach ($wpdb->get_col($query) as $metafield) { 142 142 if (preg_match("/^_/", $metafield)) continue; … … 313 313 $Order = $JSON['Order']; 314 314 if (isset($Order['Items']) && is_array($Order['Items']) && count($Order['Items']) > 0) { 315 $ItemsToAddToOrder = array(); 316 $DefaultOrderStatus = get_option("product-feeder-default-order-status"); 317 if (empty($DefaultOrderStatus)) $Errors[] = array('Type' => 'CONFIGURATION ERROR'); 318 foreach ($Order['Items'] as $Item) { 319 $product = wc_get_product($Item['ProductID']); 320 if ($product instanceof WC_Product) { 321 if (in_array($Item['VariationID'], $product->get_children())) { 322 $variation = wc_get_product($Item['VariationID']); 323 if ($variation instanceof WC_Product) $ItemsToAddToOrder[] = array('Variation' => $variation, 'Quantity' => $Item['Quantity']); 315 global $wpdb; 316 $results_order_id = $wpdb->get_results($wpdb->prepare("SELECT post_id FROM `".$wpdb->postmeta."` WHERE meta_key='product_feeder_order' AND meta_value=%s", [$Order['OrderID']]), 'OBJECT'); 317 $results_marketplace = $wpdb->get_results($wpdb->prepare("SELECT post_id FROM `".$wpdb->postmeta."` WHERE meta_key='product_feeder_marketplace' AND meta_value=%s", [$JSON['Marketplace']['Name']]), 'OBJECT'); 318 if (isset($results_order_id[0]) && isset($results_order_id[0]->post_id) && isset($results_marketplace[0]) && isset($results_marketplace[0]->post_id) && $results_order_id[0]->post_id == $results_marketplace[0]->post_id) $this->APISuccess(array('OrderID' => $results_order_id[0]->post_id)); 319 else { 320 $ItemsToAddToOrder = array(); 321 $DefaultOrderStatus = get_option("product-feeder-default-order-status"); 322 if (empty($DefaultOrderStatus)) $Errors[] = array('Type' => 'CONFIGURATION ERROR'); 323 foreach ($Order['Items'] as $Item) { 324 $product = wc_get_product($Item['ProductID']); 325 if ($product instanceof WC_Product) { 326 if (in_array($Item['VariationID'], $product->get_children())) { 327 $variation = wc_get_product($Item['VariationID']); 328 if ($variation instanceof WC_Product) $ItemsToAddToOrder[] = array('Variation' => $variation, 'Quantity' => $Item['Quantity']); 329 else $Errors[] = array('Type' => 'VARIATION NOT FOUND', 'Variables' => array('Name' => $Item['Name'], 'Variant' => $Item['Variant'], 'ProductID' => $Item['ProductID'], 'VariationID' => $Item['VariationID'])); 330 } 324 331 else $Errors[] = array('Type' => 'VARIATION NOT FOUND', 'Variables' => array('Name' => $Item['Name'], 'Variant' => $Item['Variant'], 'ProductID' => $Item['ProductID'], 'VariationID' => $Item['VariationID'])); 325 332 } 326 else $Errors[] = array('Type' => ' VARIATIONNOT FOUND', 'Variables' => array('Name' => $Item['Name'], 'Variant' => $Item['Variant'], 'ProductID' => $Item['ProductID'], 'VariationID' => $Item['VariationID']));333 else $Errors[] = array('Type' => 'PRODUCT NOT FOUND', 'Variables' => array('Name' => $Item['Name'], 'Variant' => $Item['Variant'], 'ProductID' => $Item['ProductID'], 'VariationID' => $Item['VariationID'])); 327 334 } 328 else $Errors[] = array('Type' => 'PRODUCT NOT FOUND', 'Variables' => array('Name' => $Item['Name'], 'Variant' => $Item['Variant'], 'ProductID' => $Item['ProductID'], 'VariationID' => $Item['VariationID'])); 335 if (empty($Errors)) { 336 if ($order = wc_create_order()) { 337 $OrderID = $order->get_id(); 338 $order->set_address(array( 339 'first_name' => $Order['Billing']['Firstname'], 340 'last_name' => $Order['Billing']['Lastname'], 341 'company' => $Order['Billing']['Company'], 342 'email' => $Order['Billing']['Email'], 343 'phone' => $Order['Billing']['Phone'], 344 'address_1' => $Order['Billing']['Lines'][0].((!isset($Order['Billing']['Lines'][1])) ? rtrim(' '.$Order['Billing']['HouseNumber'].' '.$Order['Billing']['HouseNumberAddition'], ' ') : ''), 345 'address_2' => (isset($Order['Billing']['Lines'][1])) ? $Order['Billing']['Lines'][1].rtrim(' '.$Order['Billing']['HouseNumber'].' '.$Order['Billing']['HouseNumberAddition'], ' ') : '', 346 'city' => $Order['Billing']['City'], 347 'state' => $Order['Billing']['State'], 348 'postcode' => $Order['Billing']['Postal'], 349 'country' => $Order['Billing']['CountryCode'] 350 ), 'billing'); 351 $order->set_address(array( 352 'first_name' => $Order['Shipping']['Firstname'], 353 'last_name' => $Order['Shipping']['Lastname'], 354 'company' => $Order['Shipping']['Company'], 355 'email' => $Order['Shipping']['Email'], 356 'phone' => $Order['Shipping']['Phone'], 357 'address_1' => $Order['Shipping']['Lines'][0].((!isset($Order['Shipping']['Lines'][1])) ? rtrim(' '.$Order['Shipping']['HouseNumber'].' '.$Order['Shipping']['HouseNumberAddition'], ' ') : ''), 358 'address_2' => (isset($Order['Shipping']['Lines'][1])) ? $Order['Shipping']['Lines'][1].rtrim(' '.$Order['Shipping']['HouseNumber'].' '.$Order['Shipping']['HouseNumberAddition'], ' ') : '', 359 'city' => $Order['Shipping']['City'], 360 'state' => $Order['Shipping']['State'], 361 'postcode' => $Order['Shipping']['Postal'], 362 'country' => $Order['Shipping']['CountryCode'] 363 ), 'shipping'); 364 foreach ($ItemsToAddToOrder as $ItemToAddToOrder) $order->add_product($ItemToAddToOrder['Variation'], $ItemToAddToOrder['Quantity']); 365 $order->calculate_totals(); 366 $order->add_order_note(sprintf(__('Order %s from marketplace %s with a total price of %s is created by Product Feeder through channel %d - %s', 'product-feeder'), $Order['ID'], $JSON['Marketplace']['Name'], strip_tags(wc_price($JSON['Order']['Price']['Amount'], array('currency' => $JSON['Order']['Price']['Currency']))), $JSON['Channel']['ID'], $JSON['Channel']['Name'])); 367 update_post_meta($OrderID, 'product_feeder_order', $Order['ID']); 368 update_post_meta($OrderID, 'product_feeder_marketplace', $JSON['Marketplace']['Name']); 369 $order->update_status($DefaultOrderStatus, '', true); 370 $this->APISuccess(array('OrderID' => $OrderID)); 371 } 372 else throw new Exception('Failed to create order template'); 373 } 374 else $this->APIError($Errors); 329 375 } 330 if (empty($Errors)) {331 if ($order = wc_create_order()) {332 $OrderID = $order->get_id();333 $order->set_address(array(334 'first_name' => $Order['Billing']['Firstname'],335 'last_name' => $Order['Billing']['Lastname'],336 'company' => $Order['Billing']['Company'],337 'email' => $Order['Billing']['Email'],338 'phone' => $Order['Billing']['Phone'],339 'address_1' => $Order['Billing']['Lines'][0].((!isset($Order['Billing']['Lines'][1])) ? rtrim(' '.$Order['Billing']['HouseNumber'].' '.$Order['Billing']['HouseNumberAddition'], ' ') : ''),340 'address_2' => (isset($Order['Billing']['Lines'][1])) ? $Order['Billing']['Lines'][1].rtrim(' '.$Order['Billing']['HouseNumber'].' '.$Order['Billing']['HouseNumberAddition'], ' ') : '',341 'city' => $Order['Billing']['City'],342 'state' => $Order['Billing']['State'],343 'postcode' => $Order['Billing']['Postal'],344 'country' => $Order['Billing']['CountryCode']345 ), 'billing');346 $order->set_address(array(347 'first_name' => $Order['Shipping']['Firstname'],348 'last_name' => $Order['Shipping']['Lastname'],349 'company' => $Order['Shipping']['Company'],350 'email' => $Order['Shipping']['Email'],351 'phone' => $Order['Shipping']['Phone'],352 'address_1' => $Order['Shipping']['Lines'][0].((!isset($Order['Shipping']['Lines'][1])) ? rtrim(' '.$Order['Shipping']['HouseNumber'].' '.$Order['Shipping']['HouseNumberAddition'], ' ') : ''),353 'address_2' => (isset($Order['Shipping']['Lines'][1])) ? $Order['Shipping']['Lines'][1].rtrim(' '.$Order['Shipping']['HouseNumber'].' '.$Order['Shipping']['HouseNumberAddition'], ' ') : '',354 'city' => $Order['Shipping']['City'],355 'state' => $Order['Shipping']['State'],356 'postcode' => $Order['Shipping']['Postal'],357 'country' => $Order['Shipping']['CountryCode']358 ), 'shipping');359 foreach ($ItemsToAddToOrder as $ItemToAddToOrder) $order->add_product($ItemToAddToOrder['Variation'], $ItemToAddToOrder['Quantity']);360 $order->calculate_totals();361 $order->add_order_note(sprintf(__('Order %s from marketplace %s with a total price of %s is created by Product Feeder through channel %d - %s', 'product-feeder'), $Order['ID'], $JSON['Marketplace']['Name'], strip_tags(wc_price($JSON['Order']['Price']['Amount'], array('currency' => $JSON['Order']['Price']['Currency']))), $JSON['Channel']['ID'], $JSON['Channel']['Name']));362 update_post_meta($OrderID, 'product_feeder_order', $Order['ID']);363 update_post_meta($OrderID, 'product_feeder_marketplace', $JSON['Marketplace']['Name']);364 $order->update_status($DefaultOrderStatus, '', true);365 $this->APISuccess(array('OrderID' => $OrderID));366 }367 else throw new Exception('Failed to create order template');368 }369 else $this->APIError($Errors);370 376 } 371 377 else throw new Exception('Incomplete ordered items information'); … … 816 822 global $wpdb; 817 823 if (!isset($this->AttributeDisplayValues[$Value])) { 818 $Term = $wpdb->get_results($wpdb->prepare("SELECT name FROM $wpdb->terms WHERE slug = '%s'", $Value), 'OBJECT');824 $Term = $wpdb->get_results($wpdb->prepare("SELECT name FROM $wpdb->terms WHERE slug = %s", $Value), 'OBJECT'); 819 825 if (isset($Term[0]) && isset($Term[0]->name)) $this->AttributeDisplayValues[$Value] = $Term[0]->name; 820 826 else $this->AttributeDisplayValues[$Value] = $Value; -
product-feeder/trunk/product-feeder.php
r3105586 r3107443 4 4 * Plugin URI: https://product-feeder.com/nl/sources/wordpress-woocommerce 5 5 * Description: Connect with various marketplaces for automated synchronization of products, orders and returns! Try it now at https://product-feeder.com 6 * Version: 2. 4.96 * Version: 2.5.0 7 7 * Author: Product Feeder 8 8 * Author URI: https://product-feeder.com -
product-feeder/trunk/readme.txt
r3105584 r3107443 5 5 Requires at least: 6.0 6 6 Tested up to: 6.4 7 Stable tag: 2. 4.97 Stable tag: 2.5.0 8 8 Requires PHP: 7.4 9 9 License: GPLv2 or later … … 135 135 = 2.4.9 = 136 136 * Optimized memory usage 137 138 = 2.5.0 = 139 * Optimized order handling
Note: See TracChangeset
for help on using the changeset viewer.