ng-easycommerce-v18 0.2.29 → 0.3.1
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.
- package/README.md +7 -0
- package/esm2022/lib/ec-components/cart-ec/cart-ec.component.mjs +8 -2
- package/esm2022/lib/ec-components/product-detail-ec/product-detail-ec.component.mjs +54 -15
- package/esm2022/lib/ec-services/cart.service.mjs +2 -2
- package/esm2022/lib/ec-services/checkout.service.mjs +46 -21
- package/esm2022/lib/ec-services/order-utility.service.mjs +2 -2
- package/fesm2022/ng-easycommerce-v18.mjs +102 -32
- package/fesm2022/ng-easycommerce-v18.mjs.map +1 -1
- package/lib/ec-components/cart-ec/cart-ec.component.d.ts +3 -0
- package/lib/ec-components/product-detail-ec/product-detail-ec.component.d.ts +4 -1
- package/package.json +1 -1
|
@@ -4538,7 +4538,7 @@ class CartService {
|
|
|
4538
4538
|
* @returns
|
|
4539
4539
|
*/
|
|
4540
4540
|
getSubTotalAmount() {
|
|
4541
|
-
return this.cart$.pipe(map((cart) => cart?.totals?.
|
|
4541
|
+
return this.cart$.pipe(map((cart) => cart?.totals?.subtotal));
|
|
4542
4542
|
}
|
|
4543
4543
|
/**
|
|
4544
4544
|
* Retorna un observable con el total del monto de las promociones aplicadas.
|
|
@@ -5039,7 +5039,7 @@ class OrderUtilityService {
|
|
|
5039
5039
|
if (cart.checkoutState && cart.checkoutState == "completed")
|
|
5040
5040
|
return;
|
|
5041
5041
|
let new_state = [];
|
|
5042
|
-
let subtotal = { type: 'subtotal', name: 'subtotal', amount: cart.totals.
|
|
5042
|
+
let subtotal = { type: 'subtotal', name: 'subtotal', amount: cart.totals.subtotal };
|
|
5043
5043
|
let total = { type: 'total', name: 'total', amount: cart.totals.total };
|
|
5044
5044
|
!forCart && new_state.push(subtotal);
|
|
5045
5045
|
for (let index = 0; index < cart.cartDiscounts.length; index++) {
|
|
@@ -5208,33 +5208,58 @@ class CheckoutService {
|
|
|
5208
5208
|
return { ok: false, require_login: false, message: 'An error occurred' };
|
|
5209
5209
|
}
|
|
5210
5210
|
};
|
|
5211
|
+
// updateAsociatedData = (cart: any) => {
|
|
5212
|
+
// let result = this._orderUtilityService.getPromotions(cart);
|
|
5213
|
+
// const userProfile: User = User.fromJson(this._authService.getUserProfileAsUser());
|
|
5214
|
+
// if (result) {
|
|
5215
|
+
// if (userProfile.isWholesaler() && cart.totals.taxes != 0) {
|
|
5216
|
+
// let total = { ...result[result.length - 1] };
|
|
5217
|
+
// result[result.length - 1] = {
|
|
5218
|
+
// type: 'taxes',
|
|
5219
|
+
// name: 'taxes',
|
|
5220
|
+
// amount: cart.totals.taxes
|
|
5221
|
+
// }
|
|
5222
|
+
// result.push(total);
|
|
5223
|
+
// }
|
|
5224
|
+
// let shipment = result?.find((promotion: any) => promotion.type == "shipment");
|
|
5225
|
+
// if (!shipment && cart.totals.shipping != 0) {
|
|
5226
|
+
// if (result?.length && !result.find((item: any) => item.type === "shipment")) {
|
|
5227
|
+
// let total = { ...result[result.length - 1] };
|
|
5228
|
+
// result[result.length - 1] = {
|
|
5229
|
+
// type: 'shipment',
|
|
5230
|
+
// name: 'shipment',
|
|
5231
|
+
// amount: cart.totals.shipping
|
|
5232
|
+
// }
|
|
5233
|
+
// result.push(total);
|
|
5234
|
+
// }
|
|
5235
|
+
// }
|
|
5236
|
+
// this._associatedDataSubject.next(result);
|
|
5237
|
+
// }
|
|
5238
|
+
// }
|
|
5211
5239
|
updateAsociatedData = (cart) => {
|
|
5212
5240
|
let result = this._orderUtilityService.getPromotions(cart);
|
|
5213
|
-
|
|
5214
|
-
|
|
5215
|
-
|
|
5241
|
+
if (cart.totals.taxes != 0 && result && result.length > 0) {
|
|
5242
|
+
let total = { ...result[result.length - 1] };
|
|
5243
|
+
result[result.length - 1] = {
|
|
5244
|
+
type: 'taxes',
|
|
5245
|
+
name: 'taxes',
|
|
5246
|
+
amount: cart.totals.taxes
|
|
5247
|
+
};
|
|
5248
|
+
result.push(total);
|
|
5249
|
+
}
|
|
5250
|
+
let shipment = result?.find(promotion => promotion.type == "shipment");
|
|
5251
|
+
if (!shipment && cart.totals.shipping != 0) {
|
|
5252
|
+
if (result?.length && !result.find(item => item.type === "shipment")) {
|
|
5216
5253
|
let total = { ...result[result.length - 1] };
|
|
5217
5254
|
result[result.length - 1] = {
|
|
5218
|
-
type: '
|
|
5219
|
-
name: '
|
|
5220
|
-
amount: cart.totals.
|
|
5255
|
+
type: 'shipment',
|
|
5256
|
+
name: 'shipment',
|
|
5257
|
+
amount: cart.totals.shipping
|
|
5221
5258
|
};
|
|
5222
5259
|
result.push(total);
|
|
5223
5260
|
}
|
|
5224
|
-
let shipment = result?.find((promotion) => promotion.type == "shipment");
|
|
5225
|
-
if (!shipment && cart.totals.shipping != 0) {
|
|
5226
|
-
if (result?.length && !result.find((item) => item.type === "shipment")) {
|
|
5227
|
-
let total = { ...result[result.length - 1] };
|
|
5228
|
-
result[result.length - 1] = {
|
|
5229
|
-
type: 'shipment',
|
|
5230
|
-
name: 'shipment',
|
|
5231
|
-
amount: cart.totals.shipping
|
|
5232
|
-
};
|
|
5233
|
-
result.push(total);
|
|
5234
|
-
}
|
|
5235
|
-
}
|
|
5236
|
-
this._associatedDataSubject.next(result);
|
|
5237
5261
|
}
|
|
5262
|
+
this._associatedDataSubject.next(result ?? null);
|
|
5238
5263
|
};
|
|
5239
5264
|
getStepData = (step_name) => {
|
|
5240
5265
|
let step_result = this._stateSubject.getValue().find(step => step.name == step_name);
|
|
@@ -8404,11 +8429,14 @@ class ProductDetailEcComponent {
|
|
|
8404
8429
|
_meta = inject(Meta);
|
|
8405
8430
|
_title = inject(Title);
|
|
8406
8431
|
_location = inject(Location);
|
|
8432
|
+
_document = inject(DOCUMENT);
|
|
8433
|
+
_platformId = inject(PLATFORM_ID);
|
|
8407
8434
|
product$ = this._productDetailService.product$;
|
|
8408
8435
|
options$ = this._productDetailService.options$;
|
|
8409
8436
|
data$ = this._productDetailService.associatedData$;
|
|
8410
8437
|
routeSubscription;
|
|
8411
8438
|
route = inject(ActivatedRoute);
|
|
8439
|
+
router = inject(Router);
|
|
8412
8440
|
currentProductId;
|
|
8413
8441
|
ngOnDestroy() {
|
|
8414
8442
|
this.routeSubscription?.unsubscribe();
|
|
@@ -8471,7 +8499,37 @@ class ProductDetailEcComponent {
|
|
|
8471
8499
|
}
|
|
8472
8500
|
updateMetaTags(product) {
|
|
8473
8501
|
const descripcionLimpia = he.decode(product.description || '').replace(/<[^>]*>/g, ' ').replace(/\s+/g, ' ').trim();
|
|
8474
|
-
|
|
8502
|
+
// Obtener URL actual compatible con SSR automáticamente
|
|
8503
|
+
let currentUrl = '';
|
|
8504
|
+
if (isPlatformBrowser(this._platformId)) {
|
|
8505
|
+
// En el navegador obtenemos la URL real actual
|
|
8506
|
+
currentUrl = this._document.location.href;
|
|
8507
|
+
}
|
|
8508
|
+
else {
|
|
8509
|
+
// Para SSR, construir URL automáticamente desde el document/request
|
|
8510
|
+
try {
|
|
8511
|
+
// Intentar obtener información del request actual
|
|
8512
|
+
const protocol = this._document.location?.protocol ||
|
|
8513
|
+
(this._document.defaultView?.location?.protocol) || 'https:';
|
|
8514
|
+
const host = this._document.location?.host ||
|
|
8515
|
+
(this._document.defaultView?.location?.host) ||
|
|
8516
|
+
this._document.location?.hostname ||
|
|
8517
|
+
'localhost';
|
|
8518
|
+
const path = this._location.path(true);
|
|
8519
|
+
// Construir URL automáticamente
|
|
8520
|
+
if (host && host !== 'localhost' && !host.includes('localhost')) {
|
|
8521
|
+
currentUrl = `${protocol}//${host}${path}`;
|
|
8522
|
+
}
|
|
8523
|
+
else {
|
|
8524
|
+
// Para casos donde no se puede detectar (development, etc.)
|
|
8525
|
+
currentUrl = path; // URL relativa como fallback
|
|
8526
|
+
}
|
|
8527
|
+
}
|
|
8528
|
+
catch (error) {
|
|
8529
|
+
// Fallback: URL relativa
|
|
8530
|
+
currentUrl = this._location.path(true);
|
|
8531
|
+
}
|
|
8532
|
+
}
|
|
8475
8533
|
this._meta.updateTag({ property: 'og:title', content: product.name || '' });
|
|
8476
8534
|
this._meta.updateTag({ property: 'og:description', content: descripcionLimpia || '' });
|
|
8477
8535
|
this._meta.updateTag({ property: 'og:image', content: this._consts.mediaImageUrl(Array.isArray(product.picturesdefault) ? product.picturesdefault[0] : product.picturesdefault) || '' });
|
|
@@ -8497,25 +8555,31 @@ class ProductDetailEcComponent {
|
|
|
8497
8555
|
}, 2000);
|
|
8498
8556
|
}
|
|
8499
8557
|
plus(stock, multipleQuantity) {
|
|
8558
|
+
const current = Number(this.quantity()); // <-- fuerza a número
|
|
8500
8559
|
if (multipleQuantity && multipleQuantity > 0) {
|
|
8501
|
-
stock
|
|
8502
|
-
?
|
|
8503
|
-
|
|
8504
|
-
|
|
8560
|
+
stock
|
|
8561
|
+
? (current < stock
|
|
8562
|
+
? this.quantity.set(current + multipleQuantity)
|
|
8563
|
+
: this._toastService.show('out-of-stock-actually'))
|
|
8564
|
+
: this.quantity.set(current + multipleQuantity);
|
|
8505
8565
|
}
|
|
8506
8566
|
else {
|
|
8507
|
-
stock
|
|
8508
|
-
?
|
|
8509
|
-
|
|
8510
|
-
|
|
8567
|
+
stock
|
|
8568
|
+
? (current < stock
|
|
8569
|
+
? this.quantity.set(current + 1)
|
|
8570
|
+
: this._toastService.show('out-of-stock-actually'))
|
|
8571
|
+
: this.quantity.set(current + 1);
|
|
8511
8572
|
}
|
|
8512
8573
|
}
|
|
8513
8574
|
less(multipleQuantity) {
|
|
8575
|
+
const current = Number(this.quantity()); // <-- fuerza a número
|
|
8514
8576
|
if (multipleQuantity && multipleQuantity > 0) {
|
|
8515
|
-
|
|
8577
|
+
current > multipleQuantity
|
|
8578
|
+
? this.quantity.set(current - multipleQuantity)
|
|
8579
|
+
: null;
|
|
8516
8580
|
}
|
|
8517
8581
|
else {
|
|
8518
|
-
|
|
8582
|
+
current > 1 ? this.quantity.set(current - 1) : null;
|
|
8519
8583
|
}
|
|
8520
8584
|
}
|
|
8521
8585
|
checkStock(stock) {
|
|
@@ -8621,13 +8685,19 @@ class CartEcComponent {
|
|
|
8621
8685
|
isAuthenticated$ = this._authService.isAuthenticated();
|
|
8622
8686
|
getTotalAmount = this._cartService.getTotalAmount();
|
|
8623
8687
|
couponCode$ = this._cartService.getCouponCode();
|
|
8688
|
+
hideTaxes = false;
|
|
8689
|
+
injector;
|
|
8624
8690
|
constructor() {
|
|
8625
8691
|
//console.log("constructo.....");
|
|
8692
|
+
this.injector = inject(Injector);
|
|
8626
8693
|
this._channelService.channel$.subscribe((res) => {
|
|
8627
8694
|
//console.log("construct")
|
|
8628
8695
|
this.channel = res;
|
|
8629
8696
|
//this.initializeSteps();
|
|
8630
8697
|
});
|
|
8698
|
+
this.injector.get(ChannelService).channel$.subscribe(channel => {
|
|
8699
|
+
this.hideTaxes = !!channel.hideTaxes;
|
|
8700
|
+
});
|
|
8631
8701
|
}
|
|
8632
8702
|
removeCoupon() {
|
|
8633
8703
|
// console.log(this.couponCode$)
|