From 4b88ff456eff6728bbc393f982482b748e91ba2f Mon Sep 17 00:00:00 2001 From: Mark Rees Date: Tue, 1 Aug 2023 11:41:55 +0200 Subject: [PATCH 1/3] add compatibilty with custom customer attributes --- Service/Magento/CreateOrderFromSubscription.php | 1 + 1 file changed, 1 insertion(+) diff --git a/Service/Magento/CreateOrderFromSubscription.php b/Service/Magento/CreateOrderFromSubscription.php index edc7c98..e41fc18 100644 --- a/Service/Magento/CreateOrderFromSubscription.php +++ b/Service/Magento/CreateOrderFromSubscription.php @@ -185,6 +185,7 @@ private function formatAddress($address): AddressInterface $quoteAddress->setSuffix($address->getSuffix()); $quoteAddress->setPrefix($address->getPrefix()); $quoteAddress->setRegionId($address->getRegionId()); + $quoteAddress->setCustomAttributes($address->getCustomAttributes()); return $quoteAddress; } From 8320ae6b316b8e51de90987279062818e639835b Mon Sep 17 00:00:00 2001 From: Michiel Gerritsen Date: Thu, 30 Nov 2023 11:31:55 +0100 Subject: [PATCH 2/3] Feature: Add option to format the next payment date --- Config.php | 6 ++++ .../SubscriptionToProductEmailVariables.php | 36 +++++++++++++++---- etc/adminhtml/system/prepayment_reminder.xml | 12 ++++++- etc/config.xml | 1 + i18n/nl_NL.csv | 2 +- 5 files changed, 49 insertions(+), 8 deletions(-) diff --git a/Config.php b/Config.php index 6144a58..124bfd9 100755 --- a/Config.php +++ b/Config.php @@ -29,6 +29,7 @@ class Config const XML_PATH_EXTENSION_SHIPPING_METHOD = 'mollie_subscriptions/general/shipping_method'; const XML_PATH_DEBUG = 'mollie_subscriptions/general/debug'; const XML_PATH_PREPAYMENT_REMINDER_DAYS_BEFORE_REMINDER = 'mollie_subscriptions/prepayment_reminder/days_before_reminder'; + const XML_PATH_PREPAYMENT_REMINDER_NEXT_PAYMENT_DATE_FORMAT = 'mollie_subscriptions/prepayment_reminder/next_payment_date_format'; const XML_PATH_PREPAYMENT_REMINDER_ENABLED = 'mollie_subscriptions/prepayment_reminder/enabled'; const XML_PATH_PREPAYMENT_REMINDER_TEMPLATE = 'mollie_subscriptions/prepayment_reminder/template'; const XML_PATH_PREPAYMENT_REMINDER_SEND_BCC_TO = 'mollie_subscriptions/prepayment_reminder/send_bcc_to'; @@ -243,6 +244,11 @@ public function daysBeforePrepaymentReminder($storeId = null, $scope = ScopeInte return $this->getStoreValue(static::XML_PATH_PREPAYMENT_REMINDER_DAYS_BEFORE_REMINDER, $storeId, $scope); } + public function nextPaymentDateFormat($storeId = null, $scope = ScopeInterface::SCOPE_STORE): string + { + return $this->getStoreValue(static::XML_PATH_PREPAYMENT_REMINDER_NEXT_PAYMENT_DATE_FORMAT, $storeId, $scope); + } + /** * @param null|int|string $storeId * @param string $scope diff --git a/Service/Email/SubscriptionToProductEmailVariables.php b/Service/Email/SubscriptionToProductEmailVariables.php index c62651a..1cf06f2 100644 --- a/Service/Email/SubscriptionToProductEmailVariables.php +++ b/Service/Email/SubscriptionToProductEmailVariables.php @@ -8,22 +8,24 @@ use Magento\Catalog\Api\ProductRepositoryInterface; use Magento\Framework\Pricing\PriceCurrencyInterface; +use Magento\Framework\Stdlib\DateTime\DateTime; use Mollie\Api\MollieApiClient; use Mollie\Api\Resources\Customer; use Mollie\Subscriptions\Api\Data\SubscriptionToProductInterface; +use Mollie\Subscriptions\Config; use Mollie\Subscriptions\Service\Mollie\MollieSubscriptionApi; class SubscriptionToProductEmailVariables { /** - * @var MollieSubscriptionApi + * @var Config */ - private $mollieSubscriptionApi; + private $config; /** - * @var Customer[] + * @var MollieSubscriptionApi */ - private $customers = []; + private $mollieSubscriptionApi; /** * @var ProductRepositoryInterface @@ -35,19 +37,31 @@ class SubscriptionToProductEmailVariables */ private $priceCurrency; + /** + * @var DateTime + */ + private $dateTime; /** * @var MollieApiClient[] */ private $apiToStore = []; + /** + * @var Customer[] + */ + private $customers = []; public function __construct( + Config $config, MollieSubscriptionApi $mollieSubscriptionApi, ProductRepositoryInterface $productRepository, - PriceCurrencyInterface $priceCurrency + PriceCurrencyInterface $priceCurrency, + DateTime $dateTime ) { + $this->config = $config; $this->mollieSubscriptionApi = $mollieSubscriptionApi; $this->productRepository = $productRepository; $this->priceCurrency = $priceCurrency; + $this->dateTime = $dateTime; } public function getMollieCustomer(SubscriptionToProductInterface $subscriptionToProduct): Customer @@ -82,10 +96,12 @@ public function get(SubscriptionToProductInterface $subscriptionToProduct): arra $subscriptionToProduct->getStoreId() ); + $date = $this->formatDate($subscription->nextPaymentDate, $subscriptionToProduct->getStoreId()); + return [ 'subscription_id' => $subscriptionToProduct->getSubscriptionId(), 'subscription_description' => $subscription->description, - 'subscription_nextPaymentDate' => $subscription->nextPaymentDate, + 'subscription_nextPaymentDate' => $date, 'subscription_amount' => $amount, 'customer_name' => $customer->name, 'customer_email' => $customer->email, @@ -102,4 +118,12 @@ private function getApiForStore($storeId): MollieApiClient $this->apiToStore[$storeId] = $this->mollieSubscriptionApi->loadByStore($storeId); return $this->apiToStore[$storeId]; } + + public function formatDate(string $nextPaymentDate, int $storeId): string + { + return $this->dateTime->date( + $this->config->nextPaymentDateFormat($storeId), + $nextPaymentDate + ); + } } diff --git a/etc/adminhtml/system/prepayment_reminder.xml b/etc/adminhtml/system/prepayment_reminder.xml index 684184f..f3febda 100644 --- a/etc/adminhtml/system/prepayment_reminder.xml +++ b/etc/adminhtml/system/prepayment_reminder.xml @@ -41,7 +41,17 @@ 1 - + + mollie_subscriptions/prepayment_reminder/next_payment_date_format + PHP date format]]> + required-entry + + 1 + + + mollie_subscriptions/prepayment_reminder/cron_expr diff --git a/etc/config.xml b/etc/config.xml index 7ddab1b..c68e422 100755 --- a/etc/config.xml +++ b/etc/config.xml @@ -24,6 +24,7 @@ 0 3 + d-m-Y 0 1 * * * diff --git a/i18n/nl_NL.csv b/i18n/nl_NL.csv index 25dd7e6..44f31d4 100644 --- a/i18n/nl_NL.csv +++ b/i18n/nl_NL.csv @@ -75,7 +75,7 @@ Type,Type "We confirm that you canceled the subscription with ID %subscription_id.","We bevestigen dat u het abonnement met ID %subscription_id heeft geannuleerd." "New subscription","Nieuw abonnement" "The customer %customerName has started a new subscription with the description %description and ID %subscription_id.","De klant %customerName heeft een nieuw abonnement gestart met de beschrijving %description en ID %subscription_id." -"Your new subscription","Uw nieuw abonnement" +"Your new subscription","Uw nieuwe abonnement" "Good news! We confirm your subscription to %product_name. The next order will be sent on its way to you on %nextPaymentDate.","Goed nieuws! We bevestigen uw abonnement op %product_name. De volgende bestelling wordt op %nextPaymentDate naar u verzonden." "Upcoming subscription renewal from %store_name","Aankomende abonnementsvernieuwing van %store_name" "We are very excited to get your %product_name subscription ready for %nextPaymentDate!","We zijn erg enthousiast om uw abonnement op %product_name klaar te maken voor %nextPaymentDate!" From f2ecf9199c32c26e6690b2b9e8cae40bdb696697 Mon Sep 17 00:00:00 2001 From: Marvin Besselsen Date: Tue, 23 Jan 2024 14:35:20 +0100 Subject: [PATCH 3/3] Version bump --- composer.json | 2 +- etc/config.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 1812a6f..b94b938 100755 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "mollie/magento2-subscriptions", "description": "Mollie subscriptions extension for Magento 2", "type": "magento2-module", - "version": "1.13.0", + "version": "1.14.0", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/etc/config.xml b/etc/config.xml index a96f406..49b4871 100755 --- a/etc/config.xml +++ b/etc/config.xml @@ -10,7 +10,7 @@ - v1.13.0 + v1.14.0 0 1