Skip to content

Commit afcc2fd

Browse files
committed
Merge remote-tracking branch 'trigger/MC-41755' into MC-41701
2 parents 4104fac + 064d828 commit afcc2fd

File tree

6 files changed

+208
-37
lines changed

6 files changed

+208
-37
lines changed

app/code/Magento/Paypal/Model/System/Config/Source/PayLater/Position.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,17 @@ public function getPositionsCPP(): array
2424
'near_pp_button' => __('Near PayPal Credit checkout button')
2525
];
2626
}
27+
28+
/**
29+
* PayLater positions source getter for Home Page
30+
*
31+
* @return array
32+
*/
33+
public function getPositionsHP(): array
34+
{
35+
return [
36+
'header' => __('Header (center)'),
37+
'sidebar' => __('Sidebar')
38+
];
39+
}
2740
}

app/code/Magento/Paypal/Setup/Patch/Data/UpdateBmltoPayLater.php

Lines changed: 81 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class UpdateBmltoPayLater implements DataPatchInterface
3434
'data' => [
3535
'position' => [
3636
'name' =>'position',
37-
'values' => ['0' => 'header', '1' => 'near_pp_button'],
37+
'values' => [['options' =>['0' => 'header', '1' => 'near_pp_button']]],
3838
'requires' => [
3939
'header' => ['name' => 'stylelayout', 'value' => 'flex'],
4040
'near_pp_button' => ['name' => 'stylelayout', 'value' => 'text']
@@ -43,14 +43,59 @@ class UpdateBmltoPayLater implements DataPatchInterface
4343
'size' => [
4444
'name' => 'ratio',
4545
'values' => [
46-
'190x100' => '8x1',
47-
'234x60' => '8x1',
48-
'300x50' => '8x1',
49-
'468x60' => '8x1',
50-
'728x90' => '20x1',
51-
'800x66' => '20x1'
52-
],
53-
'depends' => ['name' => 'position', 'value' => '0']
46+
[
47+
'options' => [
48+
'190x100' => '8x1',
49+
'234x60' => '8x1',
50+
'300x50' => '8x1',
51+
'468x60' => '8x1',
52+
'728x90' => '20x1',
53+
'800x66' => '20x1'
54+
],
55+
'depends' => ['name' => 'position', 'value' => '0']
56+
]
57+
]
58+
]
59+
]
60+
],
61+
[
62+
'pages' => ['homepage'],
63+
'data' => [
64+
'position' => [
65+
'name' =>'position',
66+
'values' => [['options' => ['0' => 'header', '1' => 'sidebar']]],
67+
'requires' => [
68+
'header' => ['name' => 'stylelayout', 'value' => 'flex'],
69+
'sidebar' => ['name' => 'stylelayout', 'value' => 'flex']
70+
]
71+
],
72+
'size' => [
73+
'name' => 'ratio',
74+
'values' => [
75+
[
76+
'options' => [
77+
'190x100' => '8x1',
78+
'234x60' => '8x1',
79+
'300x50' => '8x1',
80+
'468x60' => '8x1',
81+
'728x90' => '20x1',
82+
'800x66' => '20x1'
83+
],
84+
'depends' => ['name' => 'position', 'value' => '0']
85+
],
86+
[
87+
'options' => [
88+
'120x90' => '1x1',
89+
'190x100' => '1x1',
90+
'234x60' => '1x1',
91+
'120x240' => '1x1',
92+
'120x600' => '1x4',
93+
'234x400' => '1x1',
94+
'250x250' => '1x1'
95+
],
96+
'depends' => ['name' => 'position', 'value' => '1']
97+
]
98+
]
5499
]
55100
]
56101
]
@@ -129,39 +174,41 @@ private function convertAndSaveConfigValues(
129174
string $page,
130175
string $bmlValue
131176
) {
132-
$dependsPath = isset($pageSetting['depends'])
133-
? self::BMLPATH . $page . '_' . $pageSetting['depends']['name']
134-
: '';
135-
136-
if (!array_key_exists('depends', $pageSetting)
137-
|| (array_key_exists($dependsPath, $bmlSettings)
138-
&& $bmlSettings[$dependsPath] === $pageSetting['depends']['value'])
139-
) {
140-
$path = $payLaterPath . '_' . $pageSetting['name'];
141-
$value = $pageSetting['values'][$bmlValue];
142-
$this->moduleDataSetup->getConnection()->insertOnDuplicate(
143-
$this->moduleDataSetup->getTable('core_config_data'),
144-
[
145-
'scope' => 'default',
146-
'scope_id' => 0,
147-
'path' => $path,
148-
'value' => $value
149-
]
150-
);
151-
if (array_key_exists('requires', $pageSetting)
152-
&& array_key_exists($value, $pageSetting['requires'])
177+
foreach ($pageSetting['values'] as $pageSettingValues) {
178+
$dependsPath = isset($pageSettingValues['depends'])
179+
? self::BMLPATH . $page . '_' . $pageSettingValues['depends']['name']
180+
: '';
181+
182+
if (!array_key_exists('depends', $pageSettingValues)
183+
|| (array_key_exists($dependsPath, $bmlSettings)
184+
&& $bmlSettings[$dependsPath] === $pageSettingValues['depends']['value'])
153185
) {
154-
$requiredPath = $payLaterPath . '_' . $pageSetting['requires'][$value]['name'];
155-
$requiredValue = $pageSetting['requires'][$value]['value'];
186+
$path = $payLaterPath . '_' . $pageSetting['name'];
187+
$value = $pageSettingValues['options'][$bmlValue];
156188
$this->moduleDataSetup->getConnection()->insertOnDuplicate(
157189
$this->moduleDataSetup->getTable('core_config_data'),
158190
[
159191
'scope' => 'default',
160192
'scope_id' => 0,
161-
'path' => $requiredPath,
162-
'value' => $requiredValue
193+
'path' => $path,
194+
'value' => $value
163195
]
164196
);
197+
if (array_key_exists('requires', $pageSetting)
198+
&& array_key_exists($value, $pageSetting['requires'])
199+
) {
200+
$requiredPath = $payLaterPath . '_' . $pageSetting['requires'][$value]['name'];
201+
$requiredValue = $pageSetting['requires'][$value]['value'];
202+
$this->moduleDataSetup->getConnection()->insertOnDuplicate(
203+
$this->moduleDataSetup->getTable('core_config_data'),
204+
[
205+
'scope' => 'default',
206+
'scope_id' => 0,
207+
'path' => $requiredPath,
208+
'value' => $requiredValue
209+
]
210+
);
211+
}
165212
}
166213
}
167214
}

app/code/Magento/Paypal/etc/adminhtml/system/express_checkout.xml

Lines changed: 92 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,98 @@
341341
<depends>
342342
<field id="enable_paypal_paylater_experience">1</field>
343343
</depends>
344-
<group id="settings_paylater_productpage" translate="label" showInDefault="1" showInWebsite="1" showInStore="1" sortOrder="20">
344+
<group id="settings_paylater_homepage" translate="label" showInDefault="1" showInWebsite="1" showInStore="1" sortOrder="20">
345+
<label>Home Page</label>
346+
<depends>
347+
<field id="paylater_enabled">1</field>
348+
</depends>
349+
<field id="paylater_homepage_display" translate="label" type="select" showInDefault="1" showInWebsite="1" sortOrder="10">
350+
<label>Display</label>
351+
<config_path>payment/paypal_paylater/homepage_display</config_path>
352+
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
353+
<attribute type="shared">1</attribute>
354+
</field>
355+
<field id="paylater_homepage_position" translate="label" type="select" showInDefault="1" showInWebsite="1" sortOrder="20">
356+
<label>Position</label>
357+
<config_path>payment/paypal_paylater/homepage_position</config_path>
358+
<source_model>Magento\Paypal\Model\System\Config\Source\PayLater\Position::getPositionsHP</source_model>
359+
<attribute type="shared">1</attribute>
360+
<depends>
361+
<field id="paylater_homepage_display">1</field>
362+
</depends>
363+
</field>
364+
<field id="paylater_homepage_stylelayout" translate="label" type="select" showInDefault="1" showInWebsite="1" sortOrder="30">
365+
<label>Style Layout</label>
366+
<config_path>payment/paypal_paylater/homepage_stylelayout</config_path>
367+
<source_model>Magento\Paypal\Model\System\Config\Source\PayLater\StyleLayout</source_model>
368+
<attribute type="shared">1</attribute>
369+
<depends>
370+
<field id="paylater_homepage_display">1</field>
371+
</depends>
372+
</field>
373+
<field id="paylater_homepage_logotype" translate="label" type="select" showInDefault="1" showInWebsite="1" sortOrder="40">
374+
<label>Logo Type</label>
375+
<config_path>payment/paypal_paylater/homepage_logotype</config_path>
376+
<source_model>Magento\Paypal\Model\System\Config\Source\PayLater\LogoType</source_model>
377+
<attribute type="shared">1</attribute>
378+
<depends>
379+
<field id="paylater_homepage_display">1</field>
380+
<field id="paylater_homepage_stylelayout">text</field>
381+
</depends>
382+
</field>
383+
<field id="paylater_homepage_logoposition" translate="label" type="select" showInDefault="1" showInWebsite="1" sortOrder="50">
384+
<label>Logo Position</label>
385+
<config_path>payment/paypal_paylater/homepage_logoposition</config_path>
386+
<source_model>Magento\Paypal\Model\System\Config\Source\PayLater\LogoPosition</source_model>
387+
<attribute type="shared">1</attribute>
388+
<depends>
389+
<field id="paylater_homepage_display">1</field>
390+
<field id="paylater_homepage_stylelayout">text</field>
391+
<field id="paylater_homepage_logotype" separator=",">primary,alternative</field>
392+
</depends>
393+
</field>
394+
<field id="paylater_homepage_textcolor" translate="label" type="select" showInDefault="1" showInWebsite="1" sortOrder="60">
395+
<label>Text Color</label>
396+
<config_path>payment/paypal_paylater/homepage_textcolor</config_path>
397+
<source_model>Magento\Paypal\Model\System\Config\Source\PayLater\TextColor</source_model>
398+
<attribute type="shared">1</attribute>
399+
<depends>
400+
<field id="paylater_homepage_display">1</field>
401+
<field id="paylater_homepage_stylelayout">text</field>
402+
</depends>
403+
</field>
404+
<field id="paylater_homepage_textsize" translate="label" type="select" showInDefault="1" showInWebsite="1" sortOrder="70">
405+
<label>Text Size</label>
406+
<config_path>payment/paypal_paylater/homepage_textsize</config_path>
407+
<source_model>Magento\Paypal\Model\System\Config\Source\PayLater\TextSize</source_model>
408+
<attribute type="shared">1</attribute>
409+
<depends>
410+
<field id="paylater_homepage_display">1</field>
411+
<field id="paylater_homepage_stylelayout">text</field>
412+
</depends>
413+
</field>
414+
<field id="paylater_homepage_ratio" translate="label" type="select" showInDefault="1" showInWebsite="1" sortOrder="80">
415+
<label>Ratio</label>
416+
<config_path>payment/paypal_paylater/homepage_ratio</config_path>
417+
<source_model>Magento\Paypal\Model\System\Config\Source\PayLater\Ratio</source_model>
418+
<attribute type="shared">1</attribute>
419+
<depends>
420+
<field id="paylater_homepage_display">1</field>
421+
<field id="paylater_homepage_stylelayout">flex</field>
422+
</depends>
423+
</field>
424+
<field id="paylater_homepage_color" translate="label" type="select" showInDefault="1" showInWebsite="1" sortOrder="90">
425+
<label>Color</label>
426+
<config_path>payment/paypal_paylater/homepage_color</config_path>
427+
<source_model>Magento\Paypal\Model\System\Config\Source\PayLater\Color</source_model>
428+
<attribute type="shared">1</attribute>
429+
<depends>
430+
<field id="paylater_homepage_display">1</field>
431+
<field id="paylater_homepage_stylelayout">flex</field>
432+
</depends>
433+
</field>
434+
</group>
435+
<group id="settings_paylater_productpage" translate="label" showInDefault="1" showInWebsite="1" showInStore="1" sortOrder="30">
345436
<label>Catalog Product Page</label>
346437
<depends>
347438
<field id="paylater_enabled">1</field>

app/code/Magento/Paypal/etc/config.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,11 @@
197197
<productpage_logoposition>left</productpage_logoposition>
198198
<productpage_textcolor>black</productpage_textcolor>
199199
<productpage_textsize>12</productpage_textsize>
200+
<homepage_display>0</homepage_display>
201+
<homepage_position>header</homepage_position>
202+
<homepage_stylelayout>flex</homepage_stylelayout>
203+
<homepage_ratio>1x1</homepage_ratio>
204+
<homepage_color>blue</homepage_color>
200205
</paypal_paylater>
201206
</payment>
202207
</default>

app/code/Magento/Paypal/i18n/en_US.csv

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -749,8 +749,6 @@ User,User
749749
"White","White"
750750
"White No Border","White No Border"
751751
"Gray","Gray"
752-
"Monochrome","Monochrome"
753-
"Grayscale","Grayscale"
754752
"Left","Left"
755753
"Right","Right"
756754
"Top","Top"
@@ -763,3 +761,6 @@ User,User
763761
"Display pay later messaging on your site for offers like Pay in 3, which lets customers pay with 3 interest- free monthly payments. We’ll show messages on your site to promote this feature for you. You may not promote pay later offers with any other content, marketing, or materials","Display pay later messaging on your site for offers like Pay in 3, which lets customers pay with 3 interest- free monthly payments. We’ll show messages on your site to promote this feature for you. You may not promote pay later offers with any other content, marketing, or materials"
764762
"Enable PayPal PayLater Experience","Enable PayPal PayLater Experience"
765763
"Recommended. <strong>Advertise PayPal Credit</strong> is deprecated. See PayPal PayLater details and list of supported regions <a href="https://developer.paypal.com/docs/business/pay-later/us/#eligibility" target="_blank">here</a>.","Recommended. <strong>Advertise PayPal Credit</strong> is deprecated. See PayPal PayLater details and list of supported regions <a href="https://developer.paypal.com/docs/business/pay-later/us/#eligibility" target="_blank">here</a>.Recommended. <strong>Advertise PayPal Credit</strong> is deprecated. See PayPal PayLater details and list of supported regions <a href="https://developer.paypal.com/docs/business/pay-later/us/#eligibility" target="_blank">here</a>."
764+
"Monochrome","Monochrome"
765+
"Grayscale","Grayscale"
766+
"Sidebar","Sidebar"

app/code/Magento/Paypal/view/frontend/layout/cms_index_index.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@
1515
<argument name="position" xsi:type="number">1</argument>
1616
</arguments>
1717
</block>
18+
<block class="Magento\Paypal\Block\PayLater\Banner" name="sidebar.container.paylater"
19+
template="Magento_Paypal::paylater/banner.phtml">
20+
<arguments>
21+
<argument name="placement" xsi:type="string">home</argument>
22+
<argument name="position" xsi:type="string">sidebar</argument>
23+
</arguments>
24+
</block>
1825
</referenceContainer>
1926
<referenceContainer name="top.container">
2027
<block class="Magento\Paypal\Block\Bml\Banners" name="bml.center.logo" template="Magento_Paypal::bml.phtml">
@@ -23,6 +30,13 @@
2330
<argument name="position" xsi:type="number">0</argument>
2431
</arguments>
2532
</block>
33+
<block class="Magento\Paypal\Block\PayLater\Banner" name="top.container.paylater"
34+
template="Magento_Paypal::paylater/banner.phtml">
35+
<arguments>
36+
<argument name="placement" xsi:type="string">home</argument>
37+
<argument name="position" xsi:type="string">header</argument>
38+
</arguments>
39+
</block>
2640
</referenceContainer>
2741
</body>
2842
</page>

0 commit comments

Comments
 (0)