diff --git a/classes/controllers/LengowOrderController.php b/classes/controllers/LengowOrderController.php index b491178f..6ddf485e 100755 --- a/classes/controllers/LengowOrderController.php +++ b/classes/controllers/LengowOrderController.php @@ -152,16 +152,18 @@ public function postProcess() break; case 'save_shipping_method': $idOrder = (int) Tools::getValue('id_order'); - $shippingMethod = Tools::getValue('method'); + $shippingMethod = Tools::getValue('method', null); $response = ['success' => false, 'message' => '']; - if (!$idOrder || !$shippingMethod) { + if (!$idOrder) { $response['message'] = 'Missing parameters'; } else { try { + // Allow empty string to clear the shipping method (saves NULL in DB) + $methodValue = ($shippingMethod !== null && $shippingMethod !== '') ? pSQL($shippingMethod) : null; $result = Db::getInstance()->update( 'lengow_orders', - ['method' => pSQL($shippingMethod)], + ['method' => $methodValue], 'id_order = ' . $idOrder ); diff --git a/classes/models/LengowHook.php b/classes/models/LengowHook.php index fd84ccfe..f8ac9ab8 100755 --- a/classes/models/LengowHook.php +++ b/classes/models/LengowHook.php @@ -334,11 +334,13 @@ public function hookAdminOrderSide($params) $shippingMethods = LengowMarketplace::getValidShippingMethods($marketplaceName); $ajaxUrl = $this->context->link->getAdminLink('AdminLengowOrder', true); + $locale = new LengowTranslation(); $this->context->smarty->assign([ 'id_order' => $id_order, 'shipping_methods' => $shippingMethods, 'lengowOrder' => $lengowOrder, 'ajax_url' => $ajaxUrl, + 'lengow_locale' => $locale, ]); return $this->module->display(_PS_MODULE_LENGOW_DIR_, 'views/templates/hook/order/admin_order_side.tpl'); diff --git a/classes/models/LengowMarketplace.php b/classes/models/LengowMarketplace.php index 797232a1..753654e2 100644 --- a/classes/models/LengowMarketplace.php +++ b/classes/models/LengowMarketplace.php @@ -505,7 +505,16 @@ protected function getAllParams($action, $lengowOrder, $marketplaceArguments) $params[$arg] = $carrierName; break; case LengowAction::ARG_SHIPPING_METHOD: - $params[$arg] = $shippingMethod; + // Only send shipping_method when it is a required argument, + // or when it is optional but has a non-empty value set by the merchant. + // This prevents sending Amazon-imported default values (e.g. "Standard", "SecondDay") + // when the merchant has not explicitly chosen a shipping method. + $isRequired = isset($actions['args']) && in_array(LengowAction::ARG_SHIPPING_METHOD, $actions['args'], true); + if ($isRequired) { + $params[$arg] = $shippingMethod ?? ''; + } elseif (!empty($shippingMethod)) { + $params[$arg] = $shippingMethod; + } break; case LengowAction::ARG_RETURN_CARRIER: $idReturnCarrier = LengowOrderDetail::getOrderReturnCarrier($lengowOrder->id); diff --git a/translations/en.csv b/translations/en.csv index 8871b4ee..9ec091ed 100755 --- a/translations/en.csv +++ b/translations/en.csv @@ -471,6 +471,14 @@ admin.order.resend_action|Resend Action admin.order.check_resend_action|Do you really want to send the following action: %{action}? admin.order.customer_shipping_phone|Customer shipping phone admin.order.customer_billing_phone|Customer billing phone +admin.order.shipping_method_label|Shipping method sent by Lengow: +admin.order.shipping_method_empty|-- No shipping method selected -- +admin.order.shipping_method_custom_label|Or enter a custom value (e.g. ECONOMY): +admin.order.shipping_method_custom_help|The value entered here takes priority over the dropdown selection above. Amazon accepts free text values for this field. +admin.order.shipping_method_save|Save shipping method +admin.order.shipping_method_saved|Shipping method saved successfully. +admin.order.shipping_method_error|Error: +admin.order.shipping_method_server_error|Error communicating with server log.install.install_start|## start install for version %{version} ## log.install.install_end|## end install for version %{version} ## log.install.table_created|adding table %{name} in database diff --git a/translations/es.csv b/translations/es.csv index 975ad29f..3ed79ba7 100755 --- a/translations/es.csv +++ b/translations/es.csv @@ -471,3 +471,11 @@ admin.order.resend_action|Reenvie la accion admin.order.check_resend_action|¿Realmente desea enviar la siguiente acción: %{action} ? admin.order.customer_shipping_phone|Teléfono de envío al cliente admin.order.customer_billing_phone|Teléfono de facturación al cliente +admin.order.shipping_method_label|Método de envío enviado por Lengow: +admin.order.shipping_method_empty|-- Ningún método de envío seleccionado -- +admin.order.shipping_method_custom_label|O introduzca un valor personalizado (ej. ECONOMY): +admin.order.shipping_method_custom_help|El valor introducido aquí tendrá prioridad sobre la selección del menú desplegable. Amazon acepta valores de texto libre para este campo. +admin.order.shipping_method_save|Guardar método de envío +admin.order.shipping_method_saved|Método de envío guardado correctamente. +admin.order.shipping_method_error|Error: +admin.order.shipping_method_server_error|Error de comunicación con el servidor diff --git a/translations/fr.csv b/translations/fr.csv index ade5a057..d7539dd7 100755 --- a/translations/fr.csv +++ b/translations/fr.csv @@ -471,3 +471,11 @@ admin.order.resend_action|Renvoyer l'action admin.order.check_resend_action|Vous voulez vous vraiment renvoyer l'action %{action} ? admin.order.customer_shipping_phone|Numéro de téléphone de livraison client admin.order.customer_billing_phone|Numéro de téléphone de facturation client +admin.order.shipping_method_label|Méthode de livraison envoyée par Lengow : +admin.order.shipping_method_empty|-- Aucune méthode de livraison sélectionnée -- +admin.order.shipping_method_custom_label|Ou saisissez une valeur personnalisée (ex : ECONOMY) : +admin.order.shipping_method_custom_help|La valeur saisie ici sera prioritaire sur la sélection du menu déroulant ci-dessus. Amazon accepte des valeurs libres pour ce champ. +admin.order.shipping_method_save|Enregistrer la méthode de livraison +admin.order.shipping_method_saved|Méthode enregistrée avec succès. +admin.order.shipping_method_error|Erreur : +admin.order.shipping_method_server_error|Erreur de communication avec le serveur diff --git a/translations/it.csv b/translations/it.csv index ca465240..1d20dbd8 100755 --- a/translations/it.csv +++ b/translations/it.csv @@ -471,3 +471,11 @@ admin.order.resend_action|Re-invia Azione admin.order.check_resend_action|Vuoi veramente inviare di nuovo questa azione: %{action}? admin.order.customer_shipping_phone|Telefono per la spedizione del cliente admin.order.customer_billing_phone|Telefono per la fatturazione del cliente +admin.order.shipping_method_label|Metodo di spedizione inviato da Lengow: +admin.order.shipping_method_empty|-- Nessun metodo di spedizione selezionato -- +admin.order.shipping_method_custom_label|Oppure inserire un valore personalizzato (es. ECONOMY): +admin.order.shipping_method_custom_help|Il valore inserito qui avrà la priorità sulla selezione del menu a discesa. Amazon accetta valori di testo libero per questo campo. +admin.order.shipping_method_save|Salva metodo di spedizione +admin.order.shipping_method_saved|Metodo di spedizione salvato con successo. +admin.order.shipping_method_error|Errore: +admin.order.shipping_method_server_error|Errore di comunicazione con il server diff --git a/translations/yml/en.yml b/translations/yml/en.yml index 188604d6..c873177d 100755 --- a/translations/yml/en.yml +++ b/translations/yml/en.yml @@ -510,3 +510,11 @@ en: check_resend_action: "Do you really want to send the following action: %{action}?" customer_shipping_phone: "Customer shipping phone" customer_billing_phone: "Customer billing phone" + shipping_method_label: "Shipping method sent by Lengow:" + shipping_method_empty: "-- No shipping method selected --" + shipping_method_custom_label: "Or enter a custom value (e.g. ECONOMY):" + shipping_method_custom_help: "The value entered here takes priority over the dropdown selection above. Amazon accepts free text values for this field." + shipping_method_save: "Save shipping method" + shipping_method_saved: "Shipping method saved successfully." + shipping_method_error: "Error:" + shipping_method_server_error: "Error communicating with server" diff --git a/translations/yml/es.yml b/translations/yml/es.yml index 7a79ab00..a5df6822 100755 --- a/translations/yml/es.yml +++ b/translations/yml/es.yml @@ -510,3 +510,11 @@ es: check_resend_action: "¿Realmente desea enviar la siguiente acción: %{action} ?" customer_shipping_phone: "Teléfono de envío al cliente" customer_billing_phone: "Teléfono de facturación al cliente" + shipping_method_label: "Método de envío enviado por Lengow:" + shipping_method_empty: "-- Ningún método de envío seleccionado --" + shipping_method_custom_label: "O introduzca un valor personalizado (ej. ECONOMY):" + shipping_method_custom_help: "El valor introducido aquí tendrá prioridad sobre la selección del menú desplegable. Amazon acepta valores de texto libre para este campo." + shipping_method_save: "Guardar método de envío" + shipping_method_saved: "Método de envío guardado correctamente." + shipping_method_error: "Error:" + shipping_method_server_error: "Error de comunicación con el servidor" diff --git a/translations/yml/fr.yml b/translations/yml/fr.yml index 201603b7..781697c5 100755 --- a/translations/yml/fr.yml +++ b/translations/yml/fr.yml @@ -510,3 +510,11 @@ fr: check_resend_action: "Vous voulez vous vraiment renvoyer l'action %{action} ?" customer_shipping_phone: "Numéro de téléphone de livraison client" customer_billing_phone: "Numéro de téléphone de facturation client" + shipping_method_label: "Méthode de livraison envoyée par Lengow :" + shipping_method_empty: "-- Aucune méthode de livraison sélectionnée --" + shipping_method_custom_label: "Ou saisissez une valeur personnalisée (ex : ECONOMY) :" + shipping_method_custom_help: "La valeur saisie ici sera prioritaire sur la sélection du menu déroulant ci-dessus. Amazon accepte des valeurs libres pour ce champ." + shipping_method_save: "Enregistrer la méthode de livraison" + shipping_method_saved: "Méthode enregistrée avec succès." + shipping_method_error: "Erreur :" + shipping_method_server_error: "Erreur de communication avec le serveur" diff --git a/translations/yml/it.yml b/translations/yml/it.yml index 73bc53b7..7b587fec 100755 --- a/translations/yml/it.yml +++ b/translations/yml/it.yml @@ -510,3 +510,11 @@ it: check_resend_action: "Vuoi veramente inviare di nuovo questa azione: %{action}?" customer_shipping_phone: "Telefono per la spedizione del cliente" customer_billing_phone: "Telefono per la fatturazione del cliente" + shipping_method_label: "Metodo di spedizione inviato da Lengow:" + shipping_method_empty: "-- Nessun metodo di spedizione selezionato --" + shipping_method_custom_label: "Oppure inserire un valore personalizzato (es. ECONOMY):" + shipping_method_custom_help: "Il valore inserito qui avrà la priorità sulla selezione del menu a discesa. Amazon accetta valori di testo libero per questo campo." + shipping_method_save: "Salva metodo di spedizione" + shipping_method_saved: "Metodo di spedizione salvato con successo." + shipping_method_error: "Errore:" + shipping_method_server_error: "Errore di comunicazione con il server" diff --git a/views/templates/hook/order/admin_order_side.tpl b/views/templates/hook/order/admin_order_side.tpl index 6eadd4d2..edbd979d 100644 --- a/views/templates/hook/order/admin_order_side.tpl +++ b/views/templates/hook/order/admin_order_side.tpl @@ -21,29 +21,58 @@

Lengow Shipping

- +
- +
+ + + + {$lengow_locale->t('admin.order.shipping_method_custom_help')|escape:'html':'UTF-8'} + +
+