Compare commits
No commits in common. "77b51de48136f56ea7547274e13e7273d58ca99a" and "a39682d36354a8fbbc6b49142ab7c80db08f2655" have entirely different histories.
77b51de481
...
a39682d363
2 changed files with 4 additions and 15 deletions
6
composer.lock
generated
6
composer.lock
generated
|
|
@ -3484,15 +3484,15 @@
|
|||
},
|
||||
{
|
||||
"name": "wpackagist-plugin/falcon",
|
||||
"version": "2.9.2",
|
||||
"version": "2.8.6",
|
||||
"source": {
|
||||
"type": "svn",
|
||||
"url": "https://plugins.svn.wordpress.org/falcon/",
|
||||
"reference": "tags/2.9.2"
|
||||
"reference": "tags/2.8.6"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://downloads.wordpress.org/plugin/falcon.2.9.2.zip"
|
||||
"url": "https://downloads.wordpress.org/plugin/falcon.2.8.6.zip"
|
||||
},
|
||||
"require": {
|
||||
"composer/installers": "^1.0 || ^2.0"
|
||||
|
|
|
|||
|
|
@ -101,25 +101,14 @@ if (empty($methode_livraison['nom'])) {
|
|||
// Sélectionne la clé API Stripe
|
||||
Stripe::setApiKey(Config::get('STRIPE_API_SECRET'));
|
||||
|
||||
// TODO: Appliquer le bon calcul pour les montants vs. percentages
|
||||
function get_discount_amount(WC_Coupon $coupon) {
|
||||
if ($coupon->get_discount_type() === 'amount_off') {
|
||||
return $coupon->get_amount() * 100;
|
||||
} else {
|
||||
return $coupon->get_amount() * 100;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Met à jour les Codes promos
|
||||
$coupons_stripe = collect(Coupon::all()->data);
|
||||
$coupons_wc = collect(WC()->cart->get_coupons())
|
||||
->map(static fn(WC_Coupon $coupon): array => [
|
||||
'currency' => 'EUR',
|
||||
'duration' => 'forever',
|
||||
'fixed_cart' === $coupon->get_discount_type() ? 'amount_off' : 'percent_off' => get_discount_amount($coupon),
|
||||
'id' => $coupon->get_code(),
|
||||
'name' => $coupon->get_code(),
|
||||
'fixed_cart' === $coupon->get_discount_type() ? 'amount_off' : 'percent_off' => $coupon->get_amount(),
|
||||
])
|
||||
->each(static function (array $item) use ($coupons_stripe): void {
|
||||
// Si le code promo n'existe, le créer
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue