Clearance sale

Need to add the checkbox for clearance sale in each item record. Also need to add a customised price level to set the price for clearance.if you select clearance sale from UI then sale producers only show.

change default price level to customised level.

					_promotionItemPriceDetails: function (item) {
						var price = item.get('pricelevel99')
							, price_formatted = item.get('pricelevel99_formatted') ? item.get('pricelevel99_formatted') : item.get('onlinecustomerprice_formatted')
							, result = {};

						//console.log("item1234", item)
						if (price && price_formatted) {
							result.onlinecustomerprice = price;
							result.onlinecustomerprice_formatted = price_formatted;
							return result;
						}
						else
							return item.get('_priceDetails');
					},

For changing price level we need to change the default itemkeymapping .

						_comparePriceAgainst: function _comparePriceAgainst(item) {

							var promo_pricelevel = Configuration.PriceLevel.price;
							var promo_price_formatd = Configuration.PriceLevel.priceformtd;
							if (item.attributes.custitem65 == true) {
								Configuration.priceLevel.default = "pricelevel5";
							}
							else {
								Configuration.priceLevel.default = "pricelevel1";
							}
							var defaultprice = Configuration.priceLevel.default;
							var on_promotion = item.get('custitem65');
							var prices = item.get('_priceDetails') ? item.get('_priceDetails') : item.get('onlinecustomerprice_detail');
							var formatter = new Intl.NumberFormat('en-US', {
								style: 'currency',
								currency: 'USD',
								minimumFractionDigits: 2
							})
							var ismatrixsubitem = item.get('itemoptions_detail') ? item.get('itemoptions_detail').matrixtype : "";
							//console.log('itemnnnnnn', item)
							// for promotion items
							//if (!ismatrixsubitem) {
							if (on_promotion) {
								try {
									//console.log('itemilllll', item)
									var prices = item.get('_promotionItemPriceDetails') ? item.get('_promotionItemPriceDetails') : item.get('onlinecustomerprice_detail');
									// console.log('Configurationinside',Configuration)
									// console.log('defaultprice',defaultprice)
									// console.log('defaultprice',defaultprice)
									prices.onlinecustomerprice = item.get(promo_pricelevel);
									prices.onlinecustomerprice_formatted = item.get(promo_price_formatd);

									if (prices) {
										// console.log('hai')
										//The priceschedule is the array containing the quantity range and the price
										if (prices.priceschedule) {
											// console.log('prices.priceschedule')
											//The index 0 will be the case when the quantity is greater than 0 and lower than prices.priceschedule[0].maximumquantity
											return prices.priceschedule[0].price;
										} else {
											// console.log('defaultprice',defaultprice)
											// console.log('prices',item.get('pricelevel5'))
											return item.get('pricelevel5');
										}
									} else {
										// console.log('prices123',prices)
										//This is the default price, equivalent to onlinecustomerprice but without taking into account the amount of items into the cart
										//This value returns the 'Base Price'
										return item.get('pricelevel5') ? formatter.format(item.get('pricelevel5')) : "";
									}
								} catch (e) {
									// statements
									console.log(e);
								}

							} //promotion items 

							else {
								//console.log('itemhhhhhhhh', item)
								if (prices) {

									//The priceschedule is the array containing the quantity range and the price
									if (prices.priceschedule) {
										//The index 0 will be the case when the quantity is greater than 0 and lower than prices.priceschedule[0].maximumquantity
										return prices.priceschedule[0].price;
									} else {

										return item.get('pricelevel1');
									}
								} else {
									//This is the default price, equivalent to onlinecustomerprice but without taking into account the amount of items into the cart
									//This value returns the 'Base Price'
									return item.get('pricelevel1');
								}
								//	}
							}
						}


						_comparePriceAgainstFormated: function (item) {
							//console.log('itemnnnnnn2222', item)
							// console.log('Configuration', Configuration)
							var promo_pricelevel = Configuration.PriceLevel.price;
							var promo_price_formatd = Configuration.PriceLevel.priceformtd;
							if (item.attributes.custitem65 == true) {
								Configuration.priceLevel.default = "priceleve5";
							}
							else {
								Configuration.priceLevel.default = "pricelevel1";
							}
							var defaultprice = Configuration.priceLevel.default;
							var on_promotion = item.get('custitem65');
							var prices = item.get('_priceDetails') ? item.get('_priceDetails') : item.get('onlinecustomerprice_detail');
							var formatter = new Intl.NumberFormat('en-US', {
								style: 'currency',
								currency: 'USD',
								minimumFractionDigits: 2
							})
							var ismatrixsubitem = item.get('itemoptions_detail') ? item.get('itemoptions_detail').matrixtype : "";
							//console.log("ismatrixsubitem", ismatrixsubitem)

							//for promotion items
							//if (!ismatrixsubitem) {
							if (on_promotion) {
								try {
									//	console.log(formatter.format(item.get('pricelevel5')))
									prices.onlinecustomerprice = item.get(promo_pricelevel);
									prices.onlinecustomerprice_formatted = item.get(promo_price_formatd) ? item.get(promo_price_formatd) : formatter.format(item.get(promo_pricelevel));
									if (prices) {
										if (prices.priceschedule) {
											return prices.priceschedule[0].price_formatted;
										} else {
											// console.log('pricesfor',prices.onlinecustomerprice_formatted)
											return item.get('pricelevel5') ? formatter.format(item.get('pricelevel5')) : item.get('pricelevel1_formatted');
										}
									} else {
										return item.get('pricelevel1_formatted') ? item.get('pricelevel1_formatted') : formatter.format(item.get('pricelevel1'));
									}
								} catch (e) {
									// statements
									console.log(e);
								}

							} //promotion  

							else {
								if (prices) {
									//console.log('itempppp',item)
									if (prices.priceschedule) {
										return prices.priceschedule[0].price_formatted;
									} else {
										return item.get('pricelevel1_formatted') ? item.get('pricelevel1_formatted') : formatter.format(item.get('pricelevel1'));
									}
								} else {
									return item.get('pricelevel1_formatted') ? item.get('pricelevel1_formatted') : formatter.format(item.get('pricelevel1'));
								}
							}
						}

Leave a comment

Your email address will not be published. Required fields are marked *