From 33527f856d35f735f7e1ca6a971d5ba83f68a914 Mon Sep 17 00:00:00 2001 From: Brian Huang Date: Fri, 19 Nov 2021 17:30:56 -0500 Subject: [PATCH] UPD: Completed checkbox func --- src/components/mainPage/paypal.jsx | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/components/mainPage/paypal.jsx b/src/components/mainPage/paypal.jsx index 8975b4b..5035626 100644 --- a/src/components/mainPage/paypal.jsx +++ b/src/components/mainPage/paypal.jsx @@ -16,16 +16,17 @@ const PayPal = ({cart}) => { const createOrder = (data, actions) => { - // No idea why "cart" is still empty array... data is showing in the state (React Dev Tools) - console.log(cart); return actions.order.create({ - purchase_units: [{ - description: "Fatek B1-14MR2 PLC", - amount: { - currency_code: "USD", - value: 89.99, - } - }] + purchase_units: cart.map(item => { + return { + reference_id: item.ID, + description: item.productName, + amount: { + currency_code: "USD", + value: item.price, // using price rather than discounted price for now, (item ID 2 has discounted price: "0.00") + } + }; + }) }); } @@ -45,13 +46,13 @@ const PayPal = ({cart}) => { fundingSource={FUNDING.PAYPAL} style={{ height: 25 }} forceReRender={[cart]} + disabled={cart.length === 0} createOrder={createOrder} onApprove={onApprove} /> - {/* This is a nice touch */} {showInvoice && } );