I want to change the button style of the PayPal Express Checkout, but is not work, I have create a module to rewrite the PayPal but how I can add my changes there?
- I create di.xml file on following location
app\code\Vendor\Extension\etc\frontend\di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="\Magento\Paypal\Model\SmartButtonConfig" type="Vendor\Extension\Model\SmartButtonConfig" />
</config>
- create SmartButtonConfig.php on following location
app\code\Vendor\Extension\Model\SmartButtonConfig.php
namespace Vendor\Extension\Model;
class SmartButtonConfig extends \Magento\Paypal\Model\SmartButtonConfig
{
//do the code
}
and I have this function:
Public function:
private function getButtonStyles(string $page): array
{
$styles = $this->defaultStyles[$page];
if ((boolean)$this->config->getValue("{$page}_page_button_customize")) {
$styles['layout'] = $this->config->getValue("{$page}_page_button_layout");
$styles['size'] = $this->config->getValue("{$page}_page_button_size");
$styles['color'] = $this->config->getValue("{$page}_page_button_color");
$styles['shape'] = $this->config->getValue("{$page}_page_button_shape");
$styles['label'] = $this->config->getValue("{$page}_page_button_label");
$styles = $this->updateStyles($styles, $page);
}
return $styles;
}
I want to add only this, this are my changes:
$styles['height'] = 55;
$styles['tagline'] = false;
$styles['fundingicons'] = false;
in the private function getButtonStyles
so what I want to do is to not overwrite the vendor file. so this function private function getButtonStyles
exist already in the vendor/magento/module-paypal/Model/SmartButtonConfig.php
,
I just want to add in this function
$styles['height'] = 55;
$styles['tagline'] = false;
$styles['fundingicons'] = false;
and to be in a seperate module, because I don't want to lose the modifications when I'll upgrade the store .
Thank you
Best Answer
No need to create preference, we can use type
create:
Note: you can remove any node if don't require (i.e.checkout,cart,mini_cart,product)