ng-easycommerce-v18 0.2.19 → 0.2.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4573,7 +4573,7 @@ class CartService {
4573
4573
  fn && fn();
4574
4574
  };
4575
4575
  clearAndResetCart() {
4576
- this.resetCart(() => this.getCart);
4576
+ this.resetCart(this.getCartByCustomer); // ⚠️ FIX: Crear nuevo carrito después de completar compra
4577
4577
  }
4578
4578
  updateBalanceAttributes(balance, total = null) {
4579
4579
  if (!balance) {
@@ -5130,6 +5130,8 @@ class CheckoutService {
5130
5130
  this._canCheckoutSubject.next(false);
5131
5131
  //this._onReadySubject.next(false);
5132
5132
  this._loadingSubject.next(false);
5133
+ // ⚠️ FIX: Reset checkout data after order completion
5134
+ this.resetCheckoutState();
5133
5135
  return ({ ok: true, require_login: false, message: '' });
5134
5136
  }
5135
5137
  catch (error) {
@@ -5178,6 +5180,14 @@ class CheckoutService {
5178
5180
  this.total = data.totals.total;
5179
5181
  } */
5180
5182
  };
5183
+ // ⚠️ FIX: Reset checkout state after order completion
5184
+ resetCheckoutState = () => {
5185
+ this.checkoutData = {};
5186
+ this.order = null;
5187
+ this._stateSubject.next([]);
5188
+ this._associatedDataSubject.next(null);
5189
+ this._lastStepSubject.next(false);
5190
+ };
5181
5191
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: CheckoutService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
5182
5192
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: CheckoutService, providedIn: 'root' });
5183
5193
  }
@@ -5424,8 +5434,19 @@ class ShipmentService {
5424
5434
  this.modifyCostsResponse(res, this.getUserData().shippingAddress.postcode, method);
5425
5435
  return { success: true, order: this.order };
5426
5436
  }).then((res) => {
5427
- const firstContract = this._costsSubject.getValue();
5428
- this.setContract(firstContract);
5437
+ const costsData = this._costsSubject.getValue();
5438
+ // Extraer el primer contrato del primer método
5439
+ if (costsData && costsData.length > 0 && costsData[0].contracts && costsData[0].contracts.length > 0) {
5440
+ const firstMethod = costsData[0];
5441
+ const firstContract = firstMethod.contracts[0];
5442
+ // Construir el objeto contract_data con la estructura correcta
5443
+ const contractData = {
5444
+ ...firstContract,
5445
+ contract: firstMethod.name,
5446
+ name: firstContract.name,
5447
+ };
5448
+ this.setContract(contractData);
5449
+ }
5429
5450
  return { success: true, order: this.order };
5430
5451
  }).catch((error) => {
5431
5452
  console.log(error);