Skip to content

Commit

Permalink
using the past midnight date
Browse files Browse the repository at this point in the history
  • Loading branch information
LauraPinilla committed Nov 14, 2023
1 parent f0e4726 commit 26671e2
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions blocks/subscriptions-block/components/Cart/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,14 @@ import useSales from "../useSales";
import currency from "../../utils/currency";
import Item from "./item";

const getPaymentInfo = ({ origin, endpoint, priceCode }) =>
fetch(`${origin}${endpoint}${priceCode}/1/${new Date().getTime()}`, {}).then((res) => res.json());
const getPaymentInfo = ({ origin, endpoint, priceCode }) => {
const dateMidnight = new Date();
dateMidnight.setUTCHours(0, 0, 0, 0);

return fetch(`${origin}${endpoint}${priceCode}/1/${dateMidnight}`, {}).then((res) =>
res.json(),
);
};

const Cart = ({ offerURL, className }) => {
const { arcSite } = useFusionContext();
Expand Down Expand Up @@ -45,8 +51,8 @@ const Cart = ({ offerURL, className }) => {
fetchPaymentInfo(item.priceCode).then((priceSummary) => ({
...item,
priceSummary,
}))
)
})),
),
).then((results) => {
updatedCart.items = results;
});
Expand All @@ -58,7 +64,7 @@ const Cart = ({ offerURL, className }) => {
setCartItems(
await Sales.getCart()
.then(fetchCartItemSummaries)
.catch(() => [])
.catch(() => []),
);
setIsFetching(false);
};
Expand Down Expand Up @@ -105,4 +111,4 @@ Cart.propTypes = {
offerURL: PropTypes.string.isRequired,
};

export default Cart;
export default Cart;

0 comments on commit 26671e2

Please sign in to comment.