Skip to content

Commit 4e828e3

Browse files
authored
Merge pull request #153 from magebitcom/feature/LMM-104
LMM-104 Restyle leanpay
2 parents 0206508 + 04ac81a commit 4e828e3

21 files changed

+1673
-308
lines changed

Helper/InstallmentHelper.php

Lines changed: 358 additions & 5 deletions
Large diffs are not rendered by default.
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<?php
2+
/**
3+
* @author Magebit <info@magebit.com>
4+
* @copyright Copyright (c) Magebit, Ltd. (https://magebit.com)
5+
* @license https://magebit.com/code-license
6+
*/
7+
declare(strict_types=1);
8+
9+
namespace Leanpay\Payment\Setup\Patch\Data;
10+
11+
use Magento\Framework\App\ResourceConnection;
12+
use Magento\Framework\Setup\ModuleDataSetupInterface;
13+
use Magento\Framework\Setup\Patch\DataPatchInterface;
14+
15+
class MigrateInstallmentAdvancedConfig implements DataPatchInterface
16+
{
17+
private const PATH_MIGRATIONS = [
18+
'payment/leanpay_installment_advanced/amount_threshold' => 'payment/leanpay_installment/advanced/amount_threshold',
19+
'payment/leanpay_installment_advanced/default_installment_count' => 'payment/leanpay_installment/advanced/default_installment_count',
20+
'payment/leanpay_installment_advanced/under_threshold_text' => 'payment/leanpay_installment/advanced/under_threshold_text',
21+
'payment/leanpay_installment_advanced/plp_background_color' => 'payment/leanpay_installment/advanced/plp_background_color',
22+
'payment/leanpay_installment_advanced/pdp_text_color' => 'payment/leanpay_installment/advanced/pdp_text_color',
23+
'payment/leanpay_installment_advanced/quick_information' => 'payment/leanpay_installment/advanced/quick_information',
24+
];
25+
26+
/**
27+
* @var ModuleDataSetupInterface
28+
*/
29+
private $moduleDataSetup;
30+
31+
/**
32+
* @var ResourceConnection
33+
*/
34+
private $resource;
35+
36+
public function __construct(
37+
ModuleDataSetupInterface $moduleDataSetup,
38+
ResourceConnection $resource
39+
) {
40+
$this->moduleDataSetup = $moduleDataSetup;
41+
$this->resource = $resource;
42+
}
43+
44+
/**
45+
* @inheritdoc
46+
*/
47+
public function apply()
48+
{
49+
$this->moduleDataSetup->getConnection()->startSetup();
50+
$connection = $this->resource->getConnection(ResourceConnection::DEFAULT_CONNECTION);
51+
$table = $connection->getTableName('core_config_data');
52+
53+
foreach (self::PATH_MIGRATIONS as $oldPath => $newPath) {
54+
$connection->update(
55+
$table,
56+
['path' => $newPath],
57+
['path = ?' => $oldPath]
58+
);
59+
}
60+
61+
$this->moduleDataSetup->getConnection()->endSetup();
62+
}
63+
64+
/**
65+
* @inheritdoc
66+
*/
67+
public static function getDependencies()
68+
{
69+
return [];
70+
}
71+
72+
/**
73+
* @inheritdoc
74+
*/
75+
public function getAliases(): array
76+
{
77+
return [];
78+
}
79+
}
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<?php
2+
/**
3+
* @author Magebit <info@magebit.com>
4+
* @copyright Copyright (c) Magebit, Ltd. (https://magebit.com)
5+
* @license https://magebit.com/code-license
6+
*/
7+
declare(strict_types=1);
8+
9+
namespace Leanpay\Payment\Setup\Patch\Data;
10+
11+
use Magento\Framework\App\ResourceConnection;
12+
use Magento\Framework\Setup\ModuleDataSetupInterface;
13+
use Magento\Framework\Setup\Patch\DataPatchInterface;
14+
15+
class UpdateInstallmentAppearanceDefaults implements DataPatchInterface
16+
{
17+
private const UPDATES = [
18+
[
19+
'path' => 'payment/leanpay_installment/color',
20+
'old' => '#F58466',
21+
'new' => '#EB5A7A',
22+
],
23+
[
24+
'path' => 'payment/leanpay_installment/background_color',
25+
'old' => '#F58466',
26+
'new' => '#EB5A7A',
27+
],
28+
[
29+
'path' => 'payment/leanpay_installment/font_size_product_page',
30+
'old' => '15',
31+
'new' => '14',
32+
],
33+
[
34+
'path' => 'payment/leanpay_installment/font_size_catalog_page',
35+
'old' => '15',
36+
'new' => '12',
37+
],
38+
[
39+
'path' => 'payment/leanpay_installment/font_size_homepage',
40+
'old' => '15',
41+
'new' => '12',
42+
],
43+
];
44+
45+
/**
46+
* @var ModuleDataSetupInterface
47+
*/
48+
private $moduleDataSetup;
49+
50+
/**
51+
* @var ResourceConnection
52+
*/
53+
private $resource;
54+
55+
public function __construct(
56+
ModuleDataSetupInterface $moduleDataSetup,
57+
ResourceConnection $resource
58+
) {
59+
$this->moduleDataSetup = $moduleDataSetup;
60+
$this->resource = $resource;
61+
}
62+
63+
public function apply()
64+
{
65+
$this->moduleDataSetup->getConnection()->startSetup();
66+
67+
$connection = $this->resource->getConnection(ResourceConnection::DEFAULT_CONNECTION);
68+
$table = $connection->getTableName('core_config_data');
69+
70+
foreach (self::UPDATES as $update) {
71+
$connection->update(
72+
$table,
73+
['value' => $update['new']],
74+
['path = ?' => $update['path'], 'value = ?' => $update['old']]
75+
);
76+
}
77+
78+
$this->moduleDataSetup->getConnection()->endSetup();
79+
}
80+
81+
public static function getDependencies()
82+
{
83+
return [];
84+
}
85+
86+
public function getAliases(): array
87+
{
88+
return [];
89+
}
90+
}
91+

etc/adminhtml/system.xml

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,12 @@
146146
<field id="color" translate="label comment" sortOrder="10" type="text" showInDefault="1"
147147
showInWebsite="1" showInStore="1">
148148
<label>Color</label>
149-
<comment>Leanpay: #F58466</comment>
149+
<comment>Leanpay: #EB5A7A</comment>
150150
</field>
151151
<field id="background_color" translate="label comment" sortOrder="10" type="text" showInDefault="1"
152152
showInWebsite="1" showInStore="1">
153153
<label>Background color</label>
154-
<comment>Leanpay: #F58466</comment>
154+
<comment>Leanpay: #EB5A7A</comment>
155155
</field>
156156
<field id="font_size_homepage" translate="label comment" sortOrder="20" type="text" showInDefault="1"
157157
showInWebsite="1" showInStore="1">
@@ -193,6 +193,44 @@
193193
<label>Refresh</label>
194194
<frontend_model>Leanpay\Payment\Block\System\Config\RefreshButton</frontend_model>
195195
</field>
196+
<group id="advanced" translate="label comment" sortOrder="200" showInDefault="1"
197+
showInWebsite="1" showInStore="1">
198+
<label>Advanced</label>
199+
<comment>These settings are for advanced customization. Change only if you know what you're doing.</comment>
200+
<fieldset_css>advanced</fieldset_css>
201+
<field id="amount_threshold" translate="label comment" sortOrder="10" type="text" showInDefault="1"
202+
showInWebsite="1" showInStore="1">
203+
<label>Amount Threshold</label>
204+
<comment>Amount threshold at which the dynamic behavior changes. For amounts up to and including this value, the default installment count will be used. For amounts above this value, the maximum available installments will be selected. Default: 300</comment>
205+
<frontend_class>validate-number</frontend_class>
206+
</field>
207+
<field id="default_installment_count" translate="label comment" sortOrder="20" type="text" showInDefault="1"
208+
showInWebsite="1" showInStore="1">
209+
<label>Default Installment Count (≤ Threshold)</label>
210+
<comment>Default number of installments for amounts up to and including the threshold. Default: 3</comment>
211+
<frontend_class>validate-number</frontend_class>
212+
</field>
213+
<field id="under_threshold_text" translate="label comment" sortOrder="30" type="text" showInDefault="1"
214+
showInWebsite="1" showInStore="1">
215+
<label>Under Threshold Text</label>
216+
<comment>Text to display when amount is below threshold. Use %1 as placeholder for amount. Example: "%1 EUR"</comment>
217+
</field>
218+
<field id="plp_background_color" translate="label comment" sortOrder="40" type="text" showInDefault="1"
219+
showInWebsite="1" showInStore="1">
220+
<label>PLP Background Color</label>
221+
<comment>Background color for Product Listing Page (Category page) installment display</comment>
222+
</field>
223+
<field id="pdp_text_color" translate="label comment" sortOrder="50" type="text" showInDefault="1"
224+
showInWebsite="1" showInStore="1">
225+
<label>PDP Text Color</label>
226+
<comment>Text color for Product Detail Page installment display</comment>
227+
</field>
228+
<field id="quick_information" translate="label comment" sortOrder="60" type="textarea" showInDefault="1"
229+
showInWebsite="1" showInStore="1">
230+
<label>Installment Quick Information</label>
231+
<comment>Shown inside the installment tooltip on PDP.</comment>
232+
</field>
233+
</group>
196234
</group>
197235
</section>
198236

etc/config.xml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,23 @@
2222
</leanpay>
2323
<leanpay_installment>
2424
<model>Leanpay\Payment\Model\Method\LeanpayInstallment</model>
25-
<color>#F58466</color>
26-
<background_color>#F58466</background_color>
25+
<color>#EB5A7A</color>
26+
<background_color>#EB5A7A</background_color>
2727
<font_size_homepage>15</font_size_homepage>
28-
<font_size_product_page>15</font_size_product_page>
29-
<font_size_catalog_page>15</font_size_catalog_page>
28+
<font_size_product_page>14</font_size_product_page>
29+
<font_size_catalog_page>12</font_size_catalog_page>
3030
<more_info>https://www.leanpay.si/</more_info>
3131
<check_your_limit>https://app.leanpay.si/vendor/pre-qualified</check_your_limit>
3232
<use_dark_logo>0</use_dark_logo>
3333
<group>SPLET - REDNA PONUDBA</group>
34+
<advanced>
35+
<amount_threshold>300</amount_threshold>
36+
<default_installment_count>3</default_installment_count>
37+
<under_threshold_text>0% obresti, 0 stroškov</under_threshold_text>
38+
<plp_background_color>#EB5A7A1A</plp_background_color>
39+
<pdp_text_color>#FFFFFF</pdp_text_color>
40+
<quick_information><![CDATA[Izberi število obrokov, da dobiš mesečni izračun. V košarici izberi Leanpay in v nekaj minutah zaključi obročni nakup.]]></quick_information>
41+
</advanced>
3442
</leanpay_installment>
3543
</payment>
3644
<leanpay_promos>

i18n/hr_HR.csv

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,8 @@
1212
"Preveri svoj limit","Provjerite svoj limit"
1313
"Več informacij","Više informacija"
1414
"ali","ili"
15+
"obroki","obroci"
16+
"from %1 %2 /mesec","od %1 %2 /mjesečno"
17+
"/mesec","/mjesečno"
18+
"mes.","mj."
19+
"Izračun","Számold ki"

i18n/ro_RO.csv

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,8 @@
1313
"Več informacij","Mai multe informații"
1414
"ali od %1 %2 / mesec","de la %1 %2 / lună"
1515
"ali","sau"
16+
"obroki","rate"
17+
"from %1 %2 /mesec","de la %1 %2 /lună"
18+
"/mesec","/lună"
19+
"mes.","lun."
20+
"Izračun","Calculează"

i18n/sl_SL.csv

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,9 @@
1212
"Preveri svoj limit",
1313
"Več informacij",
1414
"ali",
15+
"obroki","obroki"
16+
"od","od"
17+
"from %1 %2 /mesec","od %1 %2 /mesec"
18+
"/mesec","/mesec"
19+
"mes.","mes."
20+
"Izračun",
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0"?>
2+
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
4+
<head>
5+
<css src="Leanpay_Payment::css/leanpay.css" />
6+
</head>
7+
</page>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0"?>
2+
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
4+
<head>
5+
<css src="Leanpay_Payment::css/leanpay.css" />
6+
</head>
7+
</page>

0 commit comments

Comments
 (0)