Changeset 3382150
- Timestamp:
- 10/21/2025 06:53:41 PM (5 months ago)
- Location:
- minicrm-woocommerce-sync/trunk
- Files:
-
- 4 edited
-
languages/minicrm-woocommerce-sync.pot (modified) (1 diff)
-
lib/Feed.php (modified) (3 diffs)
-
minicrm-woocommerce-sync.php (modified) (1 diff)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
minicrm-woocommerce-sync/trunk/languages/minicrm-woocommerce-sync.pot
r3336183 r3382150 4 4 "Project-Id-Version: MiniCRM " 5 5 "WooCommerce Sync plugin " 6 "v1.7. 5\n"6 "v1.7.6\n" 7 7 "POT-Creation-Date: 2022-05-30 " 8 8 "22:22+0200\n" -
minicrm-woocommerce-sync/trunk/lib/Feed.php
r3329264 r3382150 240 240 } 241 241 242 // Address 242 // Address - extract billing and shipping 243 243 $addresses = $business->addChild ('Addresses'); 244 $address = $addresses->addChild ('Address'); 245 246 // Try to use billing country 247 if ($latest_order->get_billing_country () !== '') { 248 try { 249 $address->CountryId = self::_getCountry ( 250 $locale, 251 $latest_order->get_billing_country () 252 ); 253 } catch (\Exception $e) {} 254 } 255 256 // Fall back to the shop's base country 257 else { 258 try { 259 $address->CountryId = self::_getCountry ( 260 $locale, 261 \WC ()->countries->get_base_country () 262 ); 263 } catch (\Exception $e) {} 264 } 265 266 $address->PostalCode = $latest_order->get_billing_postcode (); 267 $address->City = $latest_order->get_billing_city (); 268 $address->addChild ( 269 'Address', 270 trim (implode (' ', [ 271 $latest_order->get_billing_address_1 (), 272 $latest_order->get_billing_address_2 (), 273 ])) 274 ); 244 $BillingAddr = self::_extractOrderAddress ($locale, $latest_order, 'billing'); 245 if ($BillingAddr) { 246 self::_addAddressToXml ($addresses, $BillingAddr, 'Billing'); 247 } 248 $ShippingAddr = self::_extractOrderAddress ($locale, $latest_order, 'shipping'); 249 if ($ShippingAddr) { 250 self::_addAddressToXml ($addresses, $ShippingAddr, 'Shipping'); 251 } 275 252 276 253 // Email … … 296 273 $phone = $phones->addChild ('Phone'); 297 274 $phone->Value = $latest_order->get_billing_phone (); 275 276 // Add addresses to Contact if no Business node 277 if (!$company) { 278 $addresses = $contact->addChild ('Addresses'); 279 $BillingAddr = self::_extractOrderAddress ($locale, $latest_order, 'billing'); 280 if ($BillingAddr) { 281 self::_addAddressToXml ($addresses, $BillingAddr, 'Billing'); 282 } 283 $ShippingAddr = self::_extractOrderAddress ($locale, $latest_order, 'shipping'); 284 if ($ShippingAddr) { 285 self::_addAddressToXml ($addresses, $ShippingAddr, 'Shipping'); 286 } 287 } 298 288 299 289 // Orders … … 691 681 692 682 /** 683 * Extracts address data from order billing or shipping fields 684 * 685 * @param string $locale MiniCRM locale 686 * @param \WC_Order $order WooCommerce order 687 * @param string $type 'billing' or 'shipping' 688 * @return array|null Address data or null if city is empty 689 */ 690 protected static function _extractOrderAddress ( 691 string $locale, 692 \WC_Order $order, 693 string $type 694 ): ?array 695 { 696 $GetCity = "get_{$type}_city"; 697 $GetCountry = "get_{$type}_country"; 698 $GetPostcode = "get_{$type}_postcode"; 699 $GetAddress1 = "get_{$type}_address_1"; 700 $GetAddress2 = "get_{$type}_address_2"; 701 702 if ($order->$GetCity () === '') { 703 return null; 704 } 705 706 $CountryId = ''; 707 if ($order->$GetCountry () !== '') { 708 try { 709 $CountryId = self::_getCountry ($locale, $order->$GetCountry ()); 710 } catch (\Exception $e) {} 711 } else { 712 try { 713 $CountryId = self::_getCountry ($locale, \WC ()->countries->get_base_country ()); 714 } catch (\Exception $e) {} 715 } 716 717 if ($CountryId === '') { 718 return null; 719 } 720 721 return [ 722 'CountryId' => $CountryId, 723 'PostalCode' => $order->$GetPostcode (), 724 'City' => $order->$GetCity (), 725 'Address' => trim (implode (' ', [$order->$GetAddress1 (), $order->$GetAddress2 ()])), 726 ]; 727 } 728 729 /** 730 * Adds address data to an XML Addresses node 731 * 732 * @param \SimpleXMLElement $addresses Parent Addresses node 733 * @param array $addressData Address data from _extractOrderAddress 734 * @param string|null $type Optional type label (e.g., 'Billing', 'Shipping') 735 * @return void 736 */ 737 protected static function _addAddressToXml ( 738 \SimpleXMLElement $addresses, 739 array $addressData, 740 ?string $type = null 741 ): void 742 { 743 $address = $addresses->addChild ('Address'); 744 $address->CountryId = $addressData ['CountryId']; 745 $address->PostalCode = $addressData ['PostalCode']; 746 $address->City = $addressData ['City']; 747 $address->addChild ('Address', $addressData ['Address']); 748 if ($type !== null) { 749 $address->Name = $type; 750 } 751 } 752 753 /** 693 754 * Creates name string from WooCommerce order data array 694 755 * -
minicrm-woocommerce-sync/trunk/minicrm-woocommerce-sync.php
r3336183 r3382150 7 7 * License: Expat License 8 8 * Plugin Name: MiniCRM Woocommerce Sync 9 * Requires at least: 4.910 * Requires PHP: 8. 09 * Requires at least: 6.0 10 * Requires PHP: 8.1 11 11 * Text Domain: minicrm-woocommerce-sync 12 * Version: 1.7. 513 * WC requires at least: 4.0.014 * WC tested up to: 7.215 * Tested up to: 6 (non-standard header for latest major WP version supported)12 * Version: 1.7.6 13 * WC requires at least: 9.0 14 * WC tested up to: 10.2 15 * Tested up to: 6.8 16 16 * 17 17 * Copyright 2018 Tamás Márton -
minicrm-woocommerce-sync/trunk/readme.txt
r3336183 r3382150 3 3 License: Expat License 4 4 License URI: https://directory.fsf.org/wiki/License:Expat 5 Requires at least: 4.96 Requires PHP: 8. 07 Stable tag: 1.7. 58 Tested up to: 6. 29 WC requires at least: 4.0.010 WC tested up to: 7.25 Requires at least: 6.0 6 Requires PHP: 8.1 7 Stable tag: 1.7.6 8 Tested up to: 6.8 9 WC requires at least: 9.0 10 WC tested up to: 10.2 11 11 12 12 Synchronizes WooCommerce orders with your MiniCRM webshop module.
Note: See TracChangeset
for help on using the changeset viewer.