mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-04 08:47:23 +08:00
Pass default styles to the button config
This way we can overwrite it with user selected options
This commit is contained in:
parent
6f5f8b5f41
commit
18bf5497a4
2 changed files with 19 additions and 10 deletions
|
@ -1,4 +1,4 @@
|
|||
import onApprove from "./onApproveForContinue.js";
|
||||
import onApprove from './onApproveForContinue.js';
|
||||
|
||||
class CartConfig {
|
||||
|
||||
|
@ -8,31 +8,34 @@ class CartConfig {
|
|||
}
|
||||
|
||||
configuration() {
|
||||
|
||||
const createOrder = (data, actions) => {
|
||||
return fetch(this.config.ajax.create_order.endpoint, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
nonce: this.config.ajax.create_order.nonce,
|
||||
purchase_units:[]
|
||||
})
|
||||
}).then(function (res) {
|
||||
purchase_units: [],
|
||||
}),
|
||||
}).then(function(res) {
|
||||
return res.json();
|
||||
}).then(function (data) {
|
||||
}).then(function(data) {
|
||||
if (!data.success) {
|
||||
//Todo: Error handling
|
||||
return;
|
||||
}
|
||||
return data.data.id;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const style = this.config.button.style;
|
||||
|
||||
return {
|
||||
createOrder,
|
||||
onApprove:onApprove(this),
|
||||
onApprove: onApprove(this),
|
||||
onError: (error) => {
|
||||
this.errorHandler.message(error);
|
||||
}
|
||||
}
|
||||
},
|
||||
style,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -106,6 +106,12 @@ class SmartButton implements SmartButtonInterface
|
|||
'mini_cart_wrapper' => '#ppc-button-minicart',
|
||||
'cancel_wrapper' => '#ppcp-cancel',
|
||||
'url' => $smartButtonUrl,
|
||||
'style' => [
|
||||
'layout' => 'vertical',
|
||||
'color' => 'gold',
|
||||
'shape' => 'rect',
|
||||
'label' => 'paypal',
|
||||
],
|
||||
],
|
||||
];
|
||||
wp_localize_script(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue