View & Template Rendering
Checkout structure basically consists of three pages.
If the user has not logged in, it first redirects to the
Login-Register-Guestpage.If the user has logged in, it redirects to the
Checkout/Address-Paymentpage.If the order is successfully completed, it redirects to the
Successpage.
Login-Register-Guest
HTML Path: templates/orders/index.html
Included File: templates/orders/login/index.html
Js Path: templates/orders/login/index.js
Optionally, each of the forms
Login,RegisterandGuestor a combination of these can be used.When creating forms in page content,
Html(Jinja)andJavascriptshould be used together.Form macros are imported on the top of the page.
{# templates/orders/login/index.html #} {% from 'auth/_forms/loginForm.html' import LoginForm %} {% from 'auth/_forms/registerForm.html' import RegisterForm %} {% from 'auth/_forms/guestForm.html' import GuestForm %}Optionally, a
idvalue that corresponds to the ID value of<pz-form>element as a parameter can be sent when using macros.For instance, if the same form is to be used twice in mobile and desktop viewing, then the forms need to be distinguished by ID.
{# templates/orders/login/index.html #} {{ LoginForm() }} {# The default id value is "LoginForm". #} {{ LoginForm('checkout_login_form') }} {# It can also be used with the custom id value. #} {{ RegisterForm() }} {# The default id value is "RegisterForm". #} {{ RegisterForm('checkout_register_form') }} {# It can also be used with the custom id value. #} {{ GuestForm() }} {# The default id value is "GuestForm". #} {{ GuestForm('checkout_guest_form') }} {# It can also be used with the custom id value. #}LoginForm,RegisterFormandGuestFormJS classes are imported undertemplates/orders/login/index.js./* templates/orders/login/index.js */ import LoginForm from '../../auth/_forms/loginForm'; import RegisterForm from '../../auth/_forms/RegisterForm'; import GuestForm from '../../auth/_forms/guestForm';LoginForm,RegisterFormandGuestFormJS classes are called in theconstructormethod underCheckoutAuthclass oftemplates/orders/login/index.js.Form element should be sent as a parameter to each class.
/* templates/orders/login/index.js */ constructor() { new LoginForm(document.getElementById('LoginForm')); new RegisterForm(document.getElementById('RegisterForm')); new GuestForm(document.getElementById('GuestForm')); }
Checkout/Address-Payment
HTML Path: templates/orders/checkout.html
Included File: templates/orders/checkout/index.html
JS Path: templates/orders/checkout/index.js
Checkout/Address-Payment page consists of three main components, which are
Address Tab,Checkout TabandOrder Summary.When creating page content,
Html(Jinja)andJavascriptshould be used together.There are tabs on top of the page. You can switch between tabs
AddressandCheckout.Order Summaryfield is fixed on the page.Tabthere are certain functions to launch the structure.The
js-tabclass should be used for the tab button and akeythat matchescontentshould be used indata-tabattribute.The
js-tab-contentclass should be used for tab content and akeymatchingtabshould be used indata-tabattribute.
As seen in the code block above, the
./address/index.htmlfile for address tab content and the./payment/index.htmlfile for the payment tab content areinclude.Also demonstrated in the above code block, the
./summary/index.htmlfile isincludefor the order summary content.TabsandSummaryJS classes are imported undertemplates/orders/checkout/index.js.TabsandSummaryJS classes are called in theconstructormethod underCheckoutclass oftemplates/orders/checkout/index.js.
Address (Address Tab)
HTML Path: templates/orders/checkout/address/index.html
JS Path: templates/orders/checkout/address/index.js
It is the page that contains the list of addresses and shipping companies.
The address list field consists of the following components:
Information message,
List of delivery addresses,
List of invoice addresses and
Address add and edit form.
The shipping company list field consists of the following components:
Information message and
List of shipping companies.
The
templateRendererJS method is used when creating lists on top of the page.
Payment (Payment Tab)
HTML Path: templates/orders/checkout/payment/index.html
JS Path: templates/orders/checkout/payment/index.js
It is the page that contains payment methods, installment options based on payment method, and the complete order button.
There are tabs on top of the page. You can switch between available payment options tabs.
Tabthere are certain functions to launch the structure.The
js-payment-tabclass should be used for the tab button and akeythat matchescontentshould be used indata-typeattribute.The
js-payment-tab-contentclass should be used for the tab content and akeythat matchestabshould be used indata-typeattribute.
As seen in the code block above, the
./credit-card/index.htmlfile for credit card payment option tab content and the./funds-transfer/index.htmlfile for the bank transfer payment option tab content areinclude.
Summary (Order Summary)
HTML Path: templates/orders/checkout/summary/index.html
JS Path: templates/orders/checkout/summary/index.js
It is the page that includes all items in the order and item details, as well as price and discount information.
templateRenderer
JS Path: templates/utils/index.js
The
keys written in a certain format on HTML elements are matched withRegExpby JS, rendered andrenderbytemplateRenderermethod.The
keys in%_keyName_%format can be inserted in any field in the HTML elements to be used asTemplate.Templatethe content of the HTML element to be used for this purpose will be read and the action will be carried out thereThat means, the element we identified as
templatewith theidorclassdefinition will not be included in the outcome.As for JS, the HTML element we identified as
templateis selected, thekeys it contains are updated withvalues andrenderinto an element, for which an outcome is requested.
The keys in the data object matched the keys in template as they have the same title. In the
data object;
was searched and found as
%_userPk_% --> userPk,
%_userName_% --> userName,
%_userLocation_% --> userLocation,
%_userPermission_% --> userPermission and its value was received.
In the above example; the keys the data object do not have the same title as the keys in template. Therefore, a new object should be created for the second parameter of templateRenderer method and matches should be established. Otherwise, content constant will return an empty result.
Finally, the outcome will be as follows.
Last updated
Was this helpful?

