#typescript
Вопрос:
У меня есть один вопрос о том, как продолжить работу с моим кодом. Это безголовая реализация в коммерческом облаке. Если параметр retail равен true, продукт не следует удалять, а если он равен false, он должен следовать существующей логике удаления
один.тс
/** Basket parameters */ export interface BasketModelParams extends ModelParams { basketId?: string, retail?: boolean, }
два.тс
class BasketModel extends BaseModellt;Checkout.ShopperBaskets.Basket, BasketModelParamsgt; { /** Customized params for Basket model */ get params(): BasketModelParams { return { // Use ID from loaded basket data, or from original params if basket is not yet loaded basketId: (this._data.basketId || this._params.basketId) as string | undefined, }; } async validateBasket(): Promiselt;voidgt; { // TODO: check basket status, whether or not is possible to remove items. if (!this._data.productItems) { return; } const basketItems = this._data.productItems; await this.load({ variants: { product: true } }); const variants = _.flatten((this.included.variants || []) .map((v) =gt; _.get(v, [ `data`, `variants` ]))) .reduce((acc, cur) =gt; ({...acc, ...(cur ? {[cur.productId]: cur} : false) }), {}); for (const item of basketItems) { if (!!item.productId amp;amp; !_.get(variants, [ item.productId, `orderable` ], true)) { await this.removeProductItem(item); } } }
здесь мне нужно войти в систему методом проверки корзины
orderapicontroller.ts
type OrdersApiControllerParams = BasketModelParams amp; OrderModelParams amp; BasketModelUpdateParams amp; { adyenNotification: [{ NotificationRequestItem: CasperNotificationRequestItem }], couponCode?: string, retail, paymentAttributes?: RequestPaymentAttributes, } // Return all possible parameters needed for orders controller actions return { basketId: this._commerceClient?.shopperBasketId, orderNo: orderNo as string | undefined, checkoutState, couponCode: couponCode as string | undefined, email, holdForArrivalDate, marketingOptIn, productItems, shippingAddress, billingAddress, paymentAttributes, retail:retail === 'true', siteId, shippingMethodsForProductItems, adyenNotification, sendTextMessageAlerts, textMessageNumber, signatureRequired, }; Can anyone help how to implement this logic