Skip to content

Commit 9378142

Browse files
committed
MC-33420: PayPal button disappears when enable Customize Button
1 parent ac54f1b commit 9378142

File tree

4 files changed

+190
-6
lines changed

4 files changed

+190
-6
lines changed

app/code/Magento/Paypal/Model/System/Config/Source/ButtonStyles.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@ public function getShape(): array
6161
public function getSize(): array
6262
{
6363
return [
64-
'medium' => __('Medium'),
65-
'large' => __('Large'),
6664
'responsive' => __('Responsive')
6765
];
6866
}
@@ -80,7 +78,6 @@ public function getLabel(): array
8078
'buynow' => __('Buy Now'),
8179
'paypal' => __('PayPal'),
8280
'installment' => __('Installment'),
83-
'credit' => __('Credit')
8481
];
8582
}
8683

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Paypal\Setup\Patch\Data;
9+
10+
use Magento\Framework\Setup\ModuleDataSetupInterface;
11+
use Magento\Framework\Setup\Patch\DataPatchInterface;
12+
use Magento\Framework\Setup\Patch\PatchVersionInterface;
13+
14+
/**
15+
* Update existing customization for the smart button label to be compatible with the new PayPal SDK
16+
*/
17+
class UpdateSmartButtonLabel implements DataPatchInterface, PatchVersionInterface
18+
{
19+
/**
20+
* @var array
21+
*/
22+
private $labelSettingsToUpdate = [
23+
'paypal/style/checkout_page_button_label',
24+
'paypal/style/cart_page_button_label',
25+
'paypal/style/mini_cart_page_button_label',
26+
'paypal/style/product_page_button_label',
27+
];
28+
29+
/**
30+
* @var ModuleDataSetupInterface
31+
*/
32+
private $moduleDataSetup;
33+
34+
/**
35+
* PrepareInitialConfig constructor.
36+
* @param ModuleDataSetupInterface $moduleDataSetup
37+
*/
38+
public function __construct(
39+
ModuleDataSetupInterface $moduleDataSetup
40+
) {
41+
$this->moduleDataSetup = $moduleDataSetup;
42+
}
43+
44+
/**
45+
* @inheritdoc
46+
*/
47+
public function apply()
48+
{
49+
$this->moduleDataSetup->getConnection()->startSetup();
50+
$connection = $this->moduleDataSetup->getConnection();
51+
52+
$select = $connection->select()
53+
->from($this->moduleDataSetup->getTable('core_config_data'), ['path','scope', 'scope_id', 'value'])
54+
->where('path IN (?)', $this->labelSettingsToUpdate)
55+
->where('value = ?', 'credit');
56+
57+
foreach ($connection->fetchAll($select) as $pair) {
58+
$value = $pair['path'] === 'paypal/style/product_page_button_label' ? 'buynow' : 'paypal';
59+
$this->moduleDataSetup->getConnection()
60+
->insertOnDuplicate(
61+
$this->moduleDataSetup->getTable('core_config_data'),
62+
[
63+
'scope' => $pair['scope'],
64+
'scope_id' => $pair['scope_id'],
65+
'path' => $pair['path'],
66+
'value' => $value
67+
]
68+
);
69+
}
70+
return $this->moduleDataSetup->getConnection()->endSetup();
71+
}
72+
73+
/**
74+
* @inheritdoc
75+
*/
76+
public static function getDependencies()
77+
{
78+
return [];
79+
}
80+
81+
/**
82+
* @inheritdoc
83+
*/
84+
public static function getVersion()
85+
{
86+
return '2.3.1';
87+
}
88+
89+
/**
90+
* @inheritdoc
91+
*/
92+
public function getAliases()
93+
{
94+
return [];
95+
}
96+
}
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Paypal\Setup\Patch\Data;
9+
10+
use Magento\Framework\Setup\ModuleDataSetupInterface;
11+
use Magento\Framework\Setup\Patch\DataPatchInterface;
12+
use Magento\Framework\Setup\Patch\PatchVersionInterface;
13+
14+
/**
15+
* Update existing customization for the smart button size value to be compatible with the new PayPal SDK
16+
*/
17+
class UpdateSmartButtonSize implements DataPatchInterface, PatchVersionInterface
18+
{
19+
/**
20+
* @var array
21+
*/
22+
private $sizeSettingsToUpdate = [
23+
'paypal/style/checkout_page_button_size',
24+
'paypal/style/cart_page_button_size',
25+
'paypal/style/mini_cart_page_button_size',
26+
'paypal/style/checkout_page_button_size'
27+
];
28+
29+
/**
30+
* @var ModuleDataSetupInterface
31+
*/
32+
private $moduleDataSetup;
33+
34+
/**
35+
* PrepareInitialConfig constructor.
36+
* @param ModuleDataSetupInterface $moduleDataSetup
37+
*/
38+
public function __construct(
39+
ModuleDataSetupInterface $moduleDataSetup
40+
) {
41+
$this->moduleDataSetup = $moduleDataSetup;
42+
}
43+
44+
/**
45+
* @inheritdoc
46+
*/
47+
public function apply()
48+
{
49+
$this->moduleDataSetup->getConnection()->startSetup();
50+
$connection = $this->moduleDataSetup->getConnection();
51+
52+
$select = $connection->select()
53+
->from($this->moduleDataSetup->getTable('core_config_data'), ['path','scope', 'scope_id', 'value'])
54+
->where('path IN (?)', $this->sizeSettingsToUpdate)
55+
->where('value = \'large\' OR value=\'medium\'');
56+
foreach ($connection->fetchAll($select) as $pair) {
57+
$this->moduleDataSetup->getConnection()
58+
->insertOnDuplicate(
59+
$this->moduleDataSetup->getTable('core_config_data'),
60+
[
61+
'scope' => $pair['scope'],
62+
'scope_id' => $pair['scope_id'],
63+
'path' => $pair['path'],
64+
'value' => 'responsive'
65+
]
66+
);
67+
}
68+
return $this->moduleDataSetup->getConnection()->endSetup();
69+
}
70+
71+
/**
72+
* @inheritdoc
73+
*/
74+
public static function getDependencies()
75+
{
76+
return [];
77+
}
78+
79+
/**
80+
* @inheritdoc
81+
*/
82+
public static function getVersion()
83+
{
84+
return '2.3.1';
85+
}
86+
87+
/**
88+
* @inheritdoc
89+
*/
90+
public function getAliases()
91+
{
92+
return [];
93+
}
94+
}

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,6 @@ User,User
707707
"Label","Label"
708708
"The installment feature is available only in these locales: en_MX, es_MX, en_BR, pt_BR.","The installment feature is available only in these locales: en_MX, es_MX, en_BR, pt_BR."
709709
"Checkout","Checkout"
710-
"Credit","Credit"
711710
"Pay","Pay"
712711
"Buy Now","Buy Now"
713712
"PayPal","PayPal"
@@ -718,8 +717,6 @@ User,User
718717
"Vertical","Vertical"
719718
"Horizontal","Horizontal"
720719
"Size","Size"
721-
"Medium","Medium"
722-
"Large","Large"
723720
"Responsive","Responsive"
724721
"Shape","Shape"
725722
"Pill","Pill"

0 commit comments

Comments
 (0)