Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions controllers/front/AbstractOpcJsonFrontController.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php

use PrestaShop\Module\PsOnePageCheckout\Analytics\Analytics;
use PrestaShop\Module\PsOnePageCheckout\Translation\ModuleTranslation;

abstract class Ps_OnepagecheckoutAbstractOpcJsonFrontController extends ModuleFrontController
{
Expand Down Expand Up @@ -52,7 +51,7 @@ protected function buildTechnicalErrorResponse(): array
'success' => false,
'errors' => [
'' => [
$this->trans('One-page checkout is currently unavailable.', [], ModuleTranslation::SHOP_DOMAIN),
$this->trans('One-page checkout is currently unavailable.', [], 'Modules.Onepagecheckout.Shop'),
],
],
];
Expand Down
48 changes: 26 additions & 22 deletions ps_onepagecheckout.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use PrestaShop\Module\PsOnePageCheckout\Checkout\OnePageCheckoutAvailability;
use PrestaShop\Module\PsOnePageCheckout\Checkout\OnePageCheckoutProcessProvider;
use PrestaShop\Module\PsOnePageCheckout\Form\BackOfficeConfigurationForm;
use PrestaShop\Module\PsOnePageCheckout\Translation\ModuleTranslation;
use PrestaShop\PrestaShop\Adapter\Order\Checkout\CheckoutProcessProviderInterface;

class Ps_Onepagecheckout extends Module
Expand All @@ -35,7 +34,7 @@ public function __construct()

$tabNames = [];
foreach (Language::getLanguages(true) as $lang) {
$tabNames[$lang['locale']] = $this->trans('Checkout', [], ModuleTranslation::ADMIN_DOMAIN, $lang['locale']);
$tabNames[$lang['locale']] = $this->trans('Checkout', [], 'Modules.Onepagecheckout.Admin', $lang['locale']);
}
$this->tabs = [
[
Expand All @@ -44,17 +43,17 @@ public function __construct()
'name' => $tabNames,
'parent_class_name' => 'AdminParentThemes',
'wording' => 'Checkout',
'wording_domain' => ModuleTranslation::ADMIN_DOMAIN,
'wording_domain' => 'Modules.Onepagecheckout.Admin',
],
];

parent::__construct();

$this->displayName = $this->trans('One-page checkout', [], ModuleTranslation::ADMIN_DOMAIN);
$this->displayName = $this->trans('One-page checkout', [], 'Modules.Onepagecheckout.Admin');
$this->description = $this->trans(
'Native one-page checkout.',
[],
ModuleTranslation::ADMIN_DOMAIN
'Modules.Onepagecheckout.Admin'
);
$this->ps_versions_compliancy = ['min' => '9.0.0', 'max' => _PS_VERSION_];
$this->controllers = [
Expand All @@ -72,6 +71,11 @@ public function __construct()
];
}

public function isUsingNewTranslationSystem(): bool
{
return true;
}

public function install()
{
return $this->installInParent()
Expand Down Expand Up @@ -292,23 +296,23 @@ public function hookActionFrontControllerSetMedia(): void
),
],
'messages' => [
'missingGuestInitUrl' => $this->trans('Unable to initialize checkout customer.', [], ModuleTranslation::SHOP_DOMAIN),
'missingAddressFormUrl' => $this->trans('Unable to refresh addresses.', [], ModuleTranslation::SHOP_DOMAIN),
'loadCarriersFailed' => $this->trans('Unable to load delivery methods.', [], ModuleTranslation::SHOP_DOMAIN),
'missingCarrierSelectionPayload' => $this->trans('Missing delivery option.', [], ModuleTranslation::SHOP_DOMAIN),
'selectCarrierFailed' => $this->trans('Unable to select the delivery method.', [], ModuleTranslation::SHOP_DOMAIN),
'loadPaymentMethodsFailed' => $this->trans('Unable to load payment methods.', [], ModuleTranslation::SHOP_DOMAIN),
'missingPaymentSelectionPayload' => $this->trans('Missing payment selection payload.', [], ModuleTranslation::SHOP_DOMAIN),
'selectPaymentFailed' => $this->trans('Unable to select the payment method.', [], ModuleTranslation::SHOP_DOMAIN),
'statesLoadFailed' => $this->trans('Unable to load states.', [], ModuleTranslation::SHOP_DOMAIN),
'missingSaveAddressUrl' => $this->trans('Unable to save address.', [], ModuleTranslation::SHOP_DOMAIN),
'saveAddressFailed' => $this->trans('Unable to save address.', [], ModuleTranslation::SHOP_DOMAIN),
'missingDeleteAddressUrl' => $this->trans('Unable to delete address.', [], ModuleTranslation::SHOP_DOMAIN),
'deleteAddressFailed' => $this->trans('Unable to delete address.', [], ModuleTranslation::SHOP_DOMAIN),
'refreshAddressesFailed' => $this->trans('Unable to refresh addresses.', [], ModuleTranslation::SHOP_DOMAIN),
'missingPaymentForm' => $this->trans('Unable to initialize the selected payment method.', [], ModuleTranslation::SHOP_DOMAIN),
'missingSubmitUrl' => $this->trans('Unable to submit checkout.', [], ModuleTranslation::SHOP_DOMAIN),
'submitFailed' => $this->trans('Unable to submit checkout.', [], ModuleTranslation::SHOP_DOMAIN),
'missingGuestInitUrl' => $this->trans('Unable to initialize checkout customer.', [], 'Modules.Onepagecheckout.Shop'),
'missingAddressFormUrl' => $this->trans('Unable to refresh addresses.', [], 'Modules.Onepagecheckout.Shop'),
'loadCarriersFailed' => $this->trans('Unable to load delivery methods.', [], 'Modules.Onepagecheckout.Shop'),
'missingCarrierSelectionPayload' => $this->trans('Missing delivery option.', [], 'Modules.Onepagecheckout.Shop'),
'selectCarrierFailed' => $this->trans('Unable to select the delivery method.', [], 'Modules.Onepagecheckout.Shop'),
'loadPaymentMethodsFailed' => $this->trans('Unable to load payment methods.', [], 'Modules.Onepagecheckout.Shop'),
'missingPaymentSelectionPayload' => $this->trans('Missing payment selection payload.', [], 'Modules.Onepagecheckout.Shop'),
'selectPaymentFailed' => $this->trans('Unable to select the payment method.', [], 'Modules.Onepagecheckout.Shop'),
'statesLoadFailed' => $this->trans('Unable to load states.', [], 'Modules.Onepagecheckout.Shop'),
'missingSaveAddressUrl' => $this->trans('Unable to save address.', [], 'Modules.Onepagecheckout.Shop'),
'saveAddressFailed' => $this->trans('Unable to save address.', [], 'Modules.Onepagecheckout.Shop'),
'missingDeleteAddressUrl' => $this->trans('Unable to delete address.', [], 'Modules.Onepagecheckout.Shop'),
'deleteAddressFailed' => $this->trans('Unable to delete address.', [], 'Modules.Onepagecheckout.Shop'),
'refreshAddressesFailed' => $this->trans('Unable to refresh addresses.', [], 'Modules.Onepagecheckout.Shop'),
'missingPaymentForm' => $this->trans('Unable to initialize the selected payment method.', [], 'Modules.Onepagecheckout.Shop'),
'missingSubmitUrl' => $this->trans('Unable to submit checkout.', [], 'Modules.Onepagecheckout.Shop'),
'submitFailed' => $this->trans('Unable to submit checkout.', [], 'Modules.Onepagecheckout.Shop'),
],
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace PrestaShop\Module\PsOnePageCheckout\Checkout\Ajax;

use PrestaShop\Module\PsOnePageCheckout\Translation\ModuleTranslation;
use Symfony\Contracts\Translation\TranslatorInterface;

class OnePageCheckoutAddressesListHandler
Expand Down Expand Up @@ -35,7 +34,7 @@ public function handle(): array
$customer = $this->customerResolver->resolve();
if (!$customer instanceof \Customer) {
return CheckoutAjaxResponse::error(
$this->translator->trans('Unable to resolve checkout customer.', [], ModuleTranslation::SHOP_DOMAIN)
$this->translator->trans('Unable to resolve checkout customer.', [], 'Modules.Onepagecheckout.Shop')
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace PrestaShop\Module\PsOnePageCheckout\Checkout\Ajax;

use PrestaShop\Module\PsOnePageCheckout\Translation\ModuleTranslation;
use Symfony\Contracts\Translation\TranslatorInterface;

class OnePageCheckoutDeleteAddressHandler
Expand Down Expand Up @@ -34,14 +33,14 @@ public function handle(array $requestParameters = []): array
$customer = $this->customerResolver->resolve();
if (!$customer instanceof \Customer) {
return CheckoutAjaxResponse::error(
$this->translator->trans('Unable to resolve checkout customer.', [], ModuleTranslation::SHOP_DOMAIN)
$this->translator->trans('Unable to resolve checkout customer.', [], 'Modules.Onepagecheckout.Shop')
);
}

$address = $this->loadOwnedAddress($customer, (int) ($requestParameters['id_address'] ?? 0));
if (!$address instanceof \Address) {
return CheckoutAjaxResponse::error(
$this->translator->trans('Unable to load the requested address.', [], ModuleTranslation::SHOP_DOMAIN)
$this->translator->trans('Unable to load the requested address.', [], 'Modules.Onepagecheckout.Shop')
);
}

Expand All @@ -54,7 +53,7 @@ public function handle(array $requestParameters = []): array

if (!$this->buildAddressPersister($customer)->delete($address, \Tools::getToken(true, $this->context))) {
return CheckoutAjaxResponse::error(
$this->translator->trans('Unable to delete address.', [], ModuleTranslation::SHOP_DOMAIN)
$this->translator->trans('Unable to delete address.', [], 'Modules.Onepagecheckout.Shop')
);
}

Expand All @@ -75,7 +74,7 @@ public function handle(array $requestParameters = []): array
return [
'success' => true,
'id_address' => $addressId,
'message' => $this->translator->trans('Address successfully deleted.', [], ModuleTranslation::SHOP_DOMAIN),
'message' => $this->translator->trans('Address successfully deleted.', [], 'Modules.Onepagecheckout.Shop'),
];
}

Expand Down
11 changes: 5 additions & 6 deletions src/Checkout/Ajax/Address/OnePageCheckoutSaveAddressHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use PrestaShop\Module\PsOnePageCheckout\Form\OnePageCheckoutAddressForm;
use PrestaShop\Module\PsOnePageCheckout\Form\OnePageCheckoutAddressFormatter;
use PrestaShop\Module\PsOnePageCheckout\Translation\ModuleTranslation;
use Symfony\Contracts\Translation\TranslatorInterface;

class OnePageCheckoutSaveAddressHandler
Expand Down Expand Up @@ -33,7 +32,7 @@ public function handle(array $requestParameters = []): array
$customerId = $this->customerResolver->resolveId();
if ($customerId <= 0) {
return CheckoutAjaxResponse::error(
$this->translator->trans('Unable to resolve checkout customer.', [], ModuleTranslation::SHOP_DOMAIN)
$this->translator->trans('Unable to resolve checkout customer.', [], 'Modules.Onepagecheckout.Shop')
);
}

Expand All @@ -44,7 +43,7 @@ public function handle(array $requestParameters = []): array

if ($addressId > 0 && (!\Validate::isLoadedObject($address) || (int) $address->id_customer !== $customerId)) {
return CheckoutAjaxResponse::error(
$this->translator->trans('Unable to load the requested address.', [], ModuleTranslation::SHOP_DOMAIN)
$this->translator->trans('Unable to load the requested address.', [], 'Modules.Onepagecheckout.Shop')
);
}

Expand All @@ -58,7 +57,7 @@ public function handle(array $requestParameters = []): array

if (!$this->buildAddressPersister($customerId)->save($address, \Tools::getToken(true, $this->context))) {
return CheckoutAjaxResponse::error(
$this->translator->trans('Unable to save address.', [], ModuleTranslation::SHOP_DOMAIN)
$this->translator->trans('Unable to save address.', [], 'Modules.Onepagecheckout.Shop')
);
}

Expand Down Expand Up @@ -124,8 +123,8 @@ private function hydrateAddressFromForm(

$address->id_customer = $customerId;
$address->alias = trim((string) ($address->alias ?: ($addressType === 'invoice'
? $this->translator->trans('Invoice address', [], ModuleTranslation::SHOP_DOMAIN)
: $this->translator->trans('My Address', [], ModuleTranslation::SHOP_DOMAIN))));
? $this->translator->trans('Invoice address', [], 'Modules.Onepagecheckout.Shop')
: $this->translator->trans('My Address', [], 'Modules.Onepagecheckout.Shop'))));
$address->id_country = (int) $address->id_country;
$address->id_state = (int) ($address->id_state ?: 0);
\Hook::exec('actionSubmitCustomerAddressForm', ['address' => &$address]);
Expand Down
3 changes: 1 addition & 2 deletions src/Checkout/Ajax/Carrier/OnePageCheckoutCarriersHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace PrestaShop\Module\PsOnePageCheckout\Checkout\Ajax;

use PrestaShop\Module\PsOnePageCheckout\Translation\ModuleTranslation;
use Symfony\Contracts\Translation\TranslatorInterface;

class OnePageCheckoutCarriersHandler
Expand Down Expand Up @@ -54,7 +53,7 @@ public function handle(array $requestParameters = []): array
$requestedAddressId = (int) $requestParameters['id_address_delivery'];
if (!$this->isOwnedCheckoutAddress($requestedAddressId)) {
return CheckoutAjaxResponse::error(
$this->translator->trans('Invalid delivery address.', [], ModuleTranslation::SHOP_DOMAIN),
$this->translator->trans('Invalid delivery address.', [], 'Modules.Onepagecheckout.Shop'),
'id_address_delivery'
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace PrestaShop\Module\PsOnePageCheckout\Checkout\Ajax;

use PrestaShop\Module\PsOnePageCheckout\Translation\ModuleTranslation;
use Symfony\Contracts\Translation\TranslatorInterface;

class OnePageCheckoutSelectCarrierHandler
Expand Down Expand Up @@ -41,14 +40,14 @@ public function handle(array $requestParameters = []): array
$deliveryOption = (string) ($requestParameters['delivery_option'] ?? '');
if ($deliveryOption === '') {
return CheckoutAjaxResponse::error(
$this->translator->trans('Missing delivery option.', [], ModuleTranslation::SHOP_DOMAIN),
$this->translator->trans('Missing delivery option.', [], 'Modules.Onepagecheckout.Shop'),
'delivery_option'
);
}

if (!\Validate::isLoadedObject($this->context->cart)) {
return CheckoutAjaxResponse::error(
$this->translator->trans('Unable to resolve the current cart.', [], ModuleTranslation::SHOP_DOMAIN)
$this->translator->trans('Unable to resolve the current cart.', [], 'Modules.Onepagecheckout.Shop')
);
}

Expand All @@ -62,7 +61,7 @@ public function handle(array $requestParameters = []): array

if ($deliveryAddressId <= 0) {
return CheckoutAjaxResponse::error(
$this->translator->trans('Unable to resolve the current delivery address.', [], ModuleTranslation::SHOP_DOMAIN)
$this->translator->trans('Unable to resolve the current delivery address.', [], 'Modules.Onepagecheckout.Shop')
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use Db;
use PrestaShop\Module\PsOnePageCheckout\Checkout\ExistingCustomerState;
use PrestaShop\Module\PsOnePageCheckout\Form\OnePageCheckoutForm;
use PrestaShop\Module\PsOnePageCheckout\Translation\ModuleTranslation;
use PrestaShop\PrestaShop\Core\Util\InternationalizedDomainNameConverter;
use Symfony\Contracts\Translation\TranslatorInterface;

Expand Down Expand Up @@ -120,7 +119,7 @@ public function handle(array $requestParameters): array
if (!$this->isOnePageCheckoutEnabled) {
return $this->errorResponse(
self::ERROR_FIELD_GLOBAL,
$this->translator->trans('One-page checkout is not enabled.', [], ModuleTranslation::SHOP_DOMAIN)
$this->translator->trans('One-page checkout is not enabled.', [], 'Modules.Onepagecheckout.Shop')
);
}

Expand All @@ -133,7 +132,7 @@ public function handle(array $requestParameters): array
if (!$this->isTokenValid($requestParameters)) {
return $this->errorResponse(
self::ERROR_FIELD_TOKEN,
$this->translator->trans('Invalid security token.', [], ModuleTranslation::SHOP_DOMAIN),
$this->translator->trans('Invalid security token.', [], 'Modules.Onepagecheckout.Shop'),
false
);
}
Expand Down Expand Up @@ -473,7 +472,7 @@ private function resolveGuestEmail(string $submittedEmail, ExistingCustomerState
if (!$this->customerPersister->save($existingCustomer, '', '', false)) {
return $this->errorResponse(
self::ERROR_FIELD_EMAIL,
$this->translator->trans(self::ERROR_GUEST_EMAIL_UPDATE_FAILED, [], ModuleTranslation::SHOP_DOMAIN)
$this->translator->trans(self::ERROR_GUEST_EMAIL_UPDATE_FAILED, [], 'Modules.Onepagecheckout.Shop')
);
}

Expand Down Expand Up @@ -686,7 +685,7 @@ private function cartSyncErrorResponse(): array
{
return $this->errorResponse(
self::ERROR_FIELD_GLOBAL,
$this->translator->trans(self::ERROR_CART_CUSTOMER_SYNC_FAILED, [], ModuleTranslation::SHOP_DOMAIN)
$this->translator->trans(self::ERROR_CART_CUSTOMER_SYNC_FAILED, [], 'Modules.Onepagecheckout.Shop')
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use PrestaShop\Module\PsOnePageCheckout\Checkout\Ajax\OpcTempAddress;
use PrestaShop\Module\PsOnePageCheckout\Checkout\Ajax\TempAddressCarrierSelectionStorage;
use PrestaShop\Module\PsOnePageCheckout\Checkout\Ajax\TempAddressStorage;
use PrestaShop\Module\PsOnePageCheckout\Translation\ModuleTranslation;
use Symfony\Contracts\Translation\TranslatorInterface;

class OnePageCheckoutGiftWrappingHandler
Expand Down Expand Up @@ -39,13 +38,13 @@ public function handle(array $requestParameters = []): array
{
if (!\Validate::isLoadedObject($this->context->cart)) {
return CheckoutAjaxResponse::error(
$this->translator->trans('Unable to resolve the current cart.', [], ModuleTranslation::SHOP_DOMAIN)
$this->translator->trans('Unable to resolve the current cart.', [], 'Modules.Onepagecheckout.Shop')
);
}

if (!(bool) \Configuration::get('PS_GIFT_WRAPPING')) {
return CheckoutAjaxResponse::error(
$this->translator->trans('Gift wrapping is currently unavailable.', [], ModuleTranslation::SHOP_DOMAIN)
$this->translator->trans('Gift wrapping is currently unavailable.', [], 'Modules.Onepagecheckout.Shop')
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace PrestaShop\Module\PsOnePageCheckout\Checkout\Ajax;

use PrestaShop\Module\PsOnePageCheckout\Translation\ModuleTranslation;
use Symfony\Contracts\Translation\TranslatorInterface;

class OnePageCheckoutSelectPaymentHandler
Expand All @@ -29,7 +28,7 @@ public function handle(array $requestParameters = []): array

if ($this->hasMissingPaymentSelectionPayload($paymentOption, $paymentModule, $paymentSelectionKey)) {
return CheckoutAjaxResponse::error(
$this->translator->trans('Missing payment selection payload.', [], ModuleTranslation::SHOP_DOMAIN)
$this->translator->trans('Missing payment selection payload.', [], 'Modules.Onepagecheckout.Shop')
);
}

Expand Down
Loading
Loading