Basket Page - View
Login
Basket page consists of 4 main components: "Product List", "Campaigns and Discounts Area", "Cart Summary" and "Discount Form". There may be different components under the main components.
Html(Jinja)andJavascriptare used together while creating page contents.For the
Html(Jinja)andJavascriptside, thebasketobject contains the same properties.
Product Listing
HTML Path: templates/basket/basket-list/index.html
Js Path: templates/basket/basket-list/list.js
The html file of the product list is included in
templates/basket/index.htmlin the relevant field.{# templates/basket/index.html #} {% include 'basket/basket-list/index.html' %}The
BasketListandBasketListItemjs classes are imported undertemplates/basket/index.js./* templates/basket/index.js */ import BasketList from './basket-list/list'; import BasketListItem from './basket-list/item';The
BasketListjs class is called in theconstructormethod under theBasketclass intemplates/basket/index.js.When calling class; It takes the selector of the class it is called in its constructor (ie:
this.$basketContent) as a parameter and takes theBasketListItemclass as a parameter to its ownsetViewHoldermethod ./* templates/basket/index.js */ new BasketList(this.$basketContent).setViewHolder(BasketListItem);Since
BasketListis extended fromListclass, it containssetViewHoldermethod. The class passed as a parameter to thesetViewHoldermethod will be the template of the list elements.
Product
HTML Path: templates/basket/basket-list/index.html
Js Path: templates/basket/basket-list/item.js
In the
BasketListItemjs class, the html template elements in which we will fill and manipulate the data must have class names in the formatjs-basket-item-{...name...}.{# templates/basket/basket-list/index.html #} <div class="js-basket-list-item"> ... <span class="js-basket-item-product-name"><span> <span class="js-basket-item-product-price"><span> ... </div>Rendering is done in the
rendermethod under theBasketListItemjs class./* templates/basket/basket-list/item.js */ this.$productPicture.attr('src', product.productimage_set[0].image);
Basket Summary
HTML Path: templates/basket/summary/index.html
Js Path: templates/basket/summary/index.js
The html file is included in a suitable place in
templates/basket/index.htmlwhere you want the basket summary to be displayed.{# templates/basket/index.html #} {% include 'basket/summary/index.html' %}BasketSummaryjs class is imported undertemplates/basket/index.js./* templates/basket/index.js */ import { BasketSummary } from './summary';The
BasketSummaryjs class is called in theconstructormethod under theBasketclass intemplates/basket/index.js.When calling class; It takes as a parameter the selector (ie:
this.$basketContent) of the class for which it is called in its constructor./* templates/basket/index.js */ new BasketSummary(this.$basketContent);In the
BasketSummaryjs class, the html elements in which we will fill and manipulate the data must have class names in the formatjs-basket-summary-{...name...}.{# templates/basket/summary/index.html #} <div class="js-basket-summary"> ... <span class="js-basket-summary-total-product-amount"></span> ... </div>Class selectors must be written in the
constructormethod underBasketSummaryjs class./* templates/basket/summary/index.js */ this.$totalProductAmount = this.$basketSummary.find('.js-basket-summary-total-product-amount');observe(basketSelector).subscribe((basket) => {...});inconstructormethod underBasketSummaryjs class; rendering is done./* templates/basket/summary/index.js */ observe(basketSelector).subscribe((basket) => { this.$totalProductAmount.html(basket.total_product_amount); });
Discount Form
HTML Path: templates/basket/voucher-form/index.html
Js Path: templates/basket/voucher-form/index.js
The html file should be included in a suitable place in
templates/basket/index.htmlwhere the discount form is desired to be displayed.{# templates/basket/index.html #} {% include 'basket/voucher-form/index.html' %}VoucherFormjs class is imported undertemplates/basket/index.js./* templates/basket/index.js */ import VoucherForm from './voucher-form';The
VoucherFormjs class is called in theconstructor`` method under theBasketclass intemplates/basket/index.js`.When calling class; It takes as a parameter the selector (ie: ```this.$basketContent`````) of the class in which it is called in its constructor.
/* templates/basket/index.js */ new VoucherForm(this.$basketContent);In the
VoucherFormjs class, the html elements on which we will work must have class names in the formatjs-basket-voucher-form-{...name...}.{# templates/basket/voucher-form/index.html #} <pz-button class="js-basket-voucher-form-submit"> ... </pz-button>Class selectors must be written in the
constructormethod under theVoucherFormjs class./* templates/basket/voucher-form/index.js */ this.submit = this.form.querySelector('.js-basket-voucher-form-submit');Rendering is done in
observe(basketSelector).subscribe(({ voucher_code }) => {...});structure in theconstructormethod under theVoucherFormjs class./* templates/basket/voucher-form/index.js */ observe(basketSelector).subscribe(({ voucher_code }) => { ... });
Campaigns and Discounts Area
HTML Path: templates/basket/upsell-and-discount-messages/index.html
Js Path: templates/basket/upsell-and-discount-messages/index.js
The html file should be included in a suitable place in "templates/basket/index.html" where discount campaigns and discounts are desired to be displayed.
{# templates/basket/index.html #} {% include 'basket/upsell-and-discount-messages/index.html' %}UpsellAndDiscountMessagesjs class is imported undertemplates/basket/index.js./* templates/basket/index.js */ import UpsellAndDiscountMessages from './upsell-and-discount-messages';The
UpsellAndDiscountMessagesjs class is called in theconstructormethod under theBasketclass intemplates/basket/index.js.When calling class; It takes as a parameter the selector (ie:
this.$basketContent) of the class for which it is called in its constructor./* templates/basket/index.js */ new UpsellAndDiscountMessages(this.$basketContent);In the
UpsellAndDiscountMessagesjs class, the html elements in which you will fill and manipulate the data must be found in the filetemplates/basket/upsell-and-discount-messages/index.html.{# templates/basket/upsell-and-discount-messages/index.html #} <pz-carousel class="js-basket-upsell-messages"> ... </pz-carousel>Class selectors must be written in the
constructormethod under theUpsellAndDiscountMessagesjs class./* templates/basket/upsell-and-discount-messages/index.js */ this.$upsellMessages = this.$upsellAndDiscountMessages.find('.js-basket-upsell-messages');Rendering is done under
observe(basketReducer).subscribe(({ basket, pending }) => {...});in theconstructormethod under theUpsellAndDiscountMessagesjs class./* templates/basket/upsell-and-discount-messages/index.js */ observe(basketReducer).subscribe(({ basket, pending }) => { ... });
Last updated
Was this helpful?

