Changeset 3397364
- Timestamp:
- 11/17/2025 03:43:01 PM (4 months ago)
- Location:
- sync-basalam/trunk
- Files:
-
- 4 added
- 5 deleted
- 6 edited
-
includes/admin/product/class-sync-basalam-product-type-fields.php (added)
-
includes/admin/product/class-sync-basalam-product-type-fileds.php (deleted)
-
includes/class-sync-basalam-plugin.php (modified) (2 diffs)
-
includes/queue/tasks/class-sync-basalam-product-create-dispatcher.php (deleted)
-
includes/services/class-sync-basalam-order-manager.php (modified) (2 diffs)
-
includes/utilities/class-sync-basalam-convert-fa-num.php (added)
-
includes/utilities/class-sync-basalam-convet-fa-num.php (deleted)
-
includes/utilities/class-sync-basalam-get-provinces-data.php (modified) (1 diff)
-
readme.txt (modified) (1 diff)
-
sync-basalam.php (modified) (1 diff)
-
templates/admin/menu/basalam-uncync-product-page.php (deleted)
-
templates/admin/menu/basalam-unsync-product-page.php (added)
-
templates/admin/menu/main/main-connected.php (modified) (1 diff)
-
wp-bg-procces.php (deleted)
-
wp-bg-process.php (added)
Legend:
- Unmodified
- Added
- Removed
-
sync-basalam/trunk/includes/class-sync-basalam-plugin.php
r3397293 r3397364 4 4 class SyncBasalamPlugin 5 5 { 6 const VERSION = '1.5. 6';6 const VERSION = '1.5.5'; 7 7 8 8 public function __construct() … … 154 154 private function initHooks() 155 155 { 156 156 157 add_action('admin_menu', array('SyncBasalamMenus', 'registerMenus')); 157 158 -
sync-basalam/trunk/includes/services/class-sync-basalam-order-manager.php
r3397293 r3397364 152 152 $city = $data['customer_data']['city']['title'] ?? ''; 153 153 154 $stateCode = SyncBasalamGetProvincesData::getCodeByName($province); 155 156 if ($stateCode) { 157 $order->set_billing_state($stateCode); 158 $order->set_shipping_state($stateCode); 159 } 160 154 161 $full_name = $recipient['name'] ?? ''; 155 162 $first_name = ''; … … 161 168 } 162 169 163 // Set basic billing info164 170 $order->set_billing_first_name($first_name); 165 171 $order->set_billing_last_name($last_name); 166 172 $order->set_billing_address_1($recipient['postal_address'] ?? ''); 173 $order->set_billing_city($city); 167 174 $order->set_billing_postcode($recipient['postal_code'] ?? ''); 168 175 $order->set_billing_country('IR'); 169 176 $order->set_billing_phone($recipient['mobile'] ?? ''); 170 177 171 // Set basic shipping info172 178 $order->set_shipping_first_name($first_name); 173 179 $order->set_shipping_last_name($last_name); 174 180 $order->set_shipping_address_1($recipient['postal_address'] ?? ''); 181 $order->set_shipping_city($city); 175 182 $order->set_shipping_postcode($recipient['postal_code'] ?? ''); 176 183 $order->set_shipping_phone($recipient['mobile'] ?? ''); 177 184 $order->set_shipping_country('IR'); 178 179 // Set state and city with PWS compatibility180 $addressData = [181 'province' => $province,182 'city' => $city,183 ];184 SyncBasalamGetProvincesData::setOrderAddress($order, $addressData, 'billing');185 SyncBasalamGetProvincesData::setOrderAddress($order, $addressData, 'shipping');186 185 187 186 $default_method = SyncBasalamAdminSettings::getSettings(SyncBasalamAdminSettings::ORDER_SHIPPING_METHOD); -
sync-basalam/trunk/includes/utilities/class-sync-basalam-get-provinces-data.php
r3397293 r3397364 50 50 return self::$provinces[$code] ?? null; 51 51 } 52 53 /**54 * Check if Persian WooCommerce Shipping plugin is active55 */56 public static function isPWSActive(): bool57 {58 if (!function_exists('is_plugin_active')) {59 include_once(ABSPATH . 'wp-admin/includes/plugin.php');60 }61 return is_plugin_active('persian-woocommerce-shipping/persian-woocommerce-shipping.php');62 }63 64 /**65 * Set order address with PWS compatibility66 * If PWS is active, sets Tapin state/city IDs as meta data67 * Otherwise, uses normal WooCommerce state/city fields68 */69 public static function setOrderAddress($order, $addressData, $type = 'billing')70 {71 if (!$order || !isset($addressData['province']) || !isset($addressData['city'])) {72 return;73 }74 75 $province = trim($addressData['province']);76 $city = trim($addressData['city']);77 78 if (self::isPWSActive()) {79 // PWS is active - set Tapin IDs80 $state_id = self::getTapinStateIdByName($province);81 $city_id = self::getTapinCityIdByName($city, $state_id);82 83 if ($state_id) {84 $order->update_meta_data("_{$type}_state_id", $state_id);85 // Also set the state name for WooCommerce86 if ($type === 'billing') {87 $order->set_billing_state($province);88 } else {89 $order->set_shipping_state($province);90 }91 }92 93 if ($city_id) {94 $order->update_meta_data("_{$type}_city_id", $city_id);95 // Also set the city name for WooCommerce96 if ($type === 'billing') {97 $order->set_billing_city($city);98 } else {99 $order->set_shipping_city($city);100 }101 }102 } else {103 // PWS is not active - use normal WooCommerce fields104 if ($type === 'billing') {105 $order->set_billing_state($province);106 $order->set_billing_city($city);107 } else {108 $order->set_shipping_state($province);109 $order->set_shipping_city($city);110 }111 }112 }113 114 /**115 * Get Tapin state ID by Persian name116 */117 private static function getTapinStateIdByName($stateName): ?int118 {119 if (!class_exists('PWS_Tapin')) {120 return null;121 }122 123 $states = PWS_Tapin::states();124 if (!$states) {125 return null;126 }127 128 $stateName = trim($stateName);129 foreach ($states as $state_id => $state_title) {130 if (trim($state_title) === $stateName) {131 return (int) $state_id;132 }133 }134 135 return null;136 }137 138 /**139 * Get Tapin city ID by Persian name140 */141 private static function getTapinCityIdByName($cityName, $stateId = null): ?int142 {143 if (!class_exists('PWS_Tapin')) {144 return null;145 }146 147 $cities = PWS_Tapin::cities($stateId);148 if (!$cities) {149 return null;150 }151 152 $cityName = trim($cityName);153 foreach ($cities as $city_id => $city_title) {154 if (trim($city_title) === $cityName) {155 return (int) $city_id;156 }157 }158 159 return null;160 }161 52 } -
sync-basalam/trunk/readme.txt
r3397293 r3397364 5 5 Tested up to: 6.8 6 6 Requires PHP: 7.4 7 Stable tag: 1.5. 67 Stable tag: 1.5.5 8 8 License: GPL-2.0-or-later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html -
sync-basalam/trunk/sync-basalam.php
r3397293 r3397364 5 5 * Plugin Name: sync basalam | ووسلام 6 6 * Description: با استفاده از پلاگین ووسلام میتوایند تمامی محصولات ووکامرس را با یک کلیک به غرفه باسلامی خود اضافه کنید، همچنین تمامی سفارش باسلامی شما به سایت شما اضافه میگردد. 7 * Version: 1.5.6 7 * Version: 1.5.6-dev 8 8 * Author: Woosalam Dev 9 9 * Author URI: https://wp.hamsalam.ir/ -
sync-basalam/trunk/templates/admin/menu/main/main-connected.php
r3397293 r3397364 18 18 $single_update_count = $job_manager->getCountJobs(['job_type' => 'sync_basalam_update_single_product', 'status' => ['pending', 'processing']]); 19 19 20 $has_active_update_jobs = ($quick_update_processing_job || $full_update_job || $full_update_processing_job || $single_update_count > 0 );20 $has_active_update_jobs = ($quick_update_processing_job || $full_update_job || $full_update_processing_job || $single_update_count > 0 || $count_quick_update_batches > 0); 21 21 $active_update_type = ''; 22 22 if ($quick_update_processing_job) {
Note: See TracChangeset
for help on using the changeset viewer.