corvée(fmt) formate
This commit is contained in:
parent
4720c46ff8
commit
fdb6aaa7e9
23 changed files with 138 additions and 155 deletions
|
|
@ -6,12 +6,12 @@
|
|||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Roots\WPConfig\Config;
|
||||
use Stripe\BillingPortal\Session;
|
||||
use Stripe\Coupon;
|
||||
use Stripe\Product;
|
||||
use Stripe\Stripe;
|
||||
use Symfony\Component\Uid\Uuid;
|
||||
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
|
||||
|
|
@ -61,13 +61,13 @@ $panier = WC()->cart;
|
|||
/** @var string $email_client */
|
||||
$email_client = WC()->session->get('customer')['email'];
|
||||
|
||||
/** @var array<Product> $articles */
|
||||
/** @var list<Product> $articles */
|
||||
$articles = collect($panier->get_cart())
|
||||
->map(function ($article_panier) {
|
||||
$titre_produit = match ('variable' == $article_panier['data']?->get_type()) {
|
||||
->map(static function ($article_panier) {
|
||||
$titre_produit = match ('variable' === $article_panier['data']?->get_type()) {
|
||||
true => $article_panier['data']?->get_title()
|
||||
. ' ('
|
||||
. explode(': ', $article_panier['data']?->get_attribute_summary())[1]
|
||||
. explode(': ', (string) $article_panier['data']?->get_attribute_summary())[1]
|
||||
. ')',
|
||||
false => $article_panier['data']?->get_title(),
|
||||
};
|
||||
|
|
@ -91,7 +91,6 @@ $articles = collect($panier->get_cart())
|
|||
/** @var WC_Order $commande */
|
||||
$commande = wc_get_order($order_id);
|
||||
|
||||
/** @var mixed $methode_livraison */
|
||||
$methode_livraison = ['nom' => $commande->get_shipping_method(), 'cout' => $commande->get_shipping_total() * 100];
|
||||
|
||||
// Le nom de la méthode de livraison ne peut être une chaîne vide.
|
||||
|
|
@ -105,19 +104,19 @@ Stripe::setApiKey(Config::get('STRIPE_API_SECRET'));
|
|||
// Met à jour les Codes promos
|
||||
$coupons_stripe = collect(Coupon::all()->data);
|
||||
$coupons_wc = collect(WC()->cart->get_coupons())
|
||||
->map(fn(WC_Coupon $coupon) => [
|
||||
->map(static fn(WC_Coupon $coupon): array => [
|
||||
'duration' => 'forever',
|
||||
'id' => $coupon->get_code(),
|
||||
'name' => $coupon->get_code(),
|
||||
'fixed_cart' === $coupon->get_discount_type() ? 'amount_off' : 'percent_off' => $coupon->get_amount(),
|
||||
])
|
||||
->each(function (array $item) use ($coupons_stripe) {
|
||||
->each(static function (array $item) use ($coupons_stripe): void {
|
||||
// Si le code promo n'existe, le créer
|
||||
if (!$coupons_stripe->contains('name', $item['name'])) {
|
||||
Coupon::create($item);
|
||||
}
|
||||
});
|
||||
$reductions_stripe = $coupons_wc->map(fn($coupon) => ['coupon' => $coupon['name']])->values()->toArray();
|
||||
$reductions_stripe = $coupons_wc->map(static fn($coupon): array => ['coupon' => $coupon['name']])->values()->toArray();
|
||||
|
||||
/** @var Session $session_checkout_stripe */
|
||||
$session_checkout_stripe = \Stripe\Checkout\Session::create([
|
||||
|
|
@ -134,9 +133,9 @@ $session_checkout_stripe = \Stripe\Checkout\Session::create([
|
|||
'tax_behavior' => 'inclusive',
|
||||
'type' => 'fixed_amount',
|
||||
]]],
|
||||
], ['idempotency_key' => Uuid::uuid4()]);
|
||||
], ['idempotency_key' => Uuid::v4()]);
|
||||
// echo json_encode($session_checkout_stripe);
|
||||
header('HTTP/1.1 303 See Other');
|
||||
header('Location: ' . $session_checkout_stripe->url);
|
||||
|
||||
exit();
|
||||
exit;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue