Ecommerce Cart
All standard modules are designed to support ecommerce by simply enabling it using the module’s properties. Enabling ecommerce adds the Ecommerce tab to the module and allows you to begin setting up the values required for ecommerce to work. Once all of the records in a module contain the required Ecommerce values you can then create a record in the Ecommerce > Cart module or use the Default record to store items that are added to the cart. The cart module is designed to create an invisible repository for both open and closed orders and control how the cart behaves and looks.
The cart module contains four tabs: Details, Default, Summary, and Completed. The Details tab is used to give the cart a name, set up some initial values, and determine how the cart behaves. The other three tabs are used to control how the cart will look. The View property of the generated CpScript may be set to Default, Summary, or Completed and will display data using the attributes from the related tab in the module. In addition to simply displaying the data, the Completed view will clear the cart and store the order with the new status of Completed. This view should only be displayed once the final processing is completed which is typically done using Form > Thank You Message attribute. All views also generate two hidden fields, ItemQuantity and DigitalItems, which can be used within forms management for validation or processing.
The CpScript generated by this module must be included in a Form and will cause the generation of a new cart if one does not already exist. If it is included on a public page the user has not been authenticated (logged in), therefore, a temporary user id will be generated. The cart can be completed using the temporary user id, but if the user does log in the cart will be transferred to their account. The cart maintains its items across user sessions and can be integrated with Sales Tax, Shipping, Discounts, and other CpScripts. When a cart is regenerated after a user’s session expires, or the items or their quantity changes, all external data is cleared and must be reentered by the user.
Adding items to the cart is easy from the Details View (#3) of a standard module. You simply include a FormAddToCartButton CpScript in the module designer and it will automatically add the item to the cart using the values stored in the Ecommerce tab of the record. This button also automatically searches for a form item, typically a FormTextBox, in the same form group named Quantity and will add the item to the cart the provided number of times. The FormAddToCartButton may also be used on the Results View (#2) or within a Data Source, but the setup is a bit more complicated. First you must be sure to add the Group and UniqueIdColumn properties to the button and all related form items so that it does not use the default group and creates a unique form per record. You also must explicitly assign the DataId of the item that you want added to the cart. You do this by adding a FormHiddenField with the same Group and UniqueIdColumn and the following additional properties: Id=’DataId’, and DefaultValue=’cpsys_Constant:ColumnData:DataId’. The DataId column must exist when using this technique within a DataSource. You can also set up a FormHiddenField called Origin if you wish to populate the documents originating URL manually. If you are on a standard modules results view you can even set defaultValue='BuildUrl' to have the appropriate URL generated for the record.
You can also add integrated items to the cart. An integrated item is any item that does not have a DataId and therefore is not automatically recognized by the system. It is typically displayed on the site using Data Sources. In this case you simply create form items, typically FormHiddenField CpScripts, containing the following Id’s: IntegrationId, Title, Summary, OriginalPrice, CurrentPrice, DimWeight, IsTaxable, and Type. These form items will usually have the DefaultValue property set using cpsys_Constant:ColumnData:ColumnName. The item will be added to the cart using these values instead of the values stored in the module’s ecommerce tab. Since integrated items cannot be verified by the system many cart features are not supported.
Some items require additional information like Size or Color. The system supports this kind of item and calls this additional information Variants. Variants are added to an item by adding a form item, typically FormRadioButtonList, containing the appropriate Group and UniqueIdColumn when necessary and setting the property Variant=’Message displayed when the variant is not selected.’ This new variant property is supported in all standard CpScripting Form controls when used with a FormAddToCartButton. Be aware that variants will not work with cart validation based on stock or the maximum quantity per user because these values are only set once per item, not per variant.
Finally, the FormAddToCartButton may be included within Default > Item Content attribute of the Cart module itself. In this case you must set Group=’OrderItem’ and UniqueIdColumn=’OrderItemId’ so that the button works in coordination with the order item hidden fields generated by the system. You can also add a FormTextBox CpScript with the Id=’Quantity’ to allow the user to enter the quantity, but in this case the quantity will replace the items current quantity instead of adding to it. This CpScript must also use the same Group and UniqueIdColumn as the button itself. You may add a Remove=’true’ property to cause the button to remove an item from the cart instead of looking for a DataId text box, but changing the Quantity to 0 will also remove an item from the cart. If you wish the form buttons (next, previous, submit, custom) to automatically update the cart item quantities you cannot use individual item update buttons and you should change the Id of the FormTextBox to '{0}_Quantity'. In this case you must also include the cart on every page of the form so that it is available to update the item quantities. If you have a page where you do not want the cart you may use the view='Hidden' property of the cart CpScript.
This module contains a Custom Provider module property which developers can use to override standard cart methods like InsertItem. To use this property you must first create a class which inherits from Centralpoint.WebSite.Ecommerce.Cart. It can be created in a my_Modules or Custom file/folder and namespace depending on whether you want it to sync to all sites or use it in select sites. This class must override both public constructors as demonstrated in this example. It can then override any virtual method in the inherited Cart class. Be aware that overriding a method, especially without calling the base method, may cause compatibility issues in future updates. Be sure to watch the sync notes and test any ecommerce related changes in the development site before syncing to a production site when this module property is in use. Once the class is created the module property should be set to the complete type name, e.g., Centralpoint.WebSite.Custom.TemplateCart.
Ecommerce Sales Tax
You can setup an Sales Tax for your Ecommerce in Ecommerce > Sales Tax Module.
This module let you setup international or local tax rates for regular product or a digital product.
FormAddressInfo cp:script will retrieve appropriate tax rates based on user billing information and set those rates in cart of the user.
CartDownloadDigitalItems
This script will display URL for Digital Items which were purchased. It can be used in thank you page or in the email.
[cp:literal:scripting key='CartDownloadDigitalItems' id='DigitalItems' usefullyqualifiedurl='' /]
| Property |
Description |
| usefullyqualifiedurl |
true or false. Optional value. need to be set to true if this script used in email. |
| Format |
A format string used to prefix or suffix the return value. Include '{0}' in the string where you would like the value to be placed. |
Add Additional payment method(
In order to add additional payment mended you need to follow next steps:
1. Cart Checkout From add additional page and shift Editor HTML from page 3 to page 4 and page 4 to page 5.
2. On page 3 and FormRadioButtonList csript SystemType='KeywordList' SystemName='PaymentMethod' and apply validator to that control.
Example:
[cp:scripting key='FormRadioButtonList' id='PaymentMethod' SystemType='KeywordList' SystemName='PaymentMethod' defaultValue='CreditCard' /]
[cp:scripting key='FormRequiredFieldValidator' id='reqPaymentMethod' itemToValidate='PaymentMethod' defaultValue='Please select a Payment Method'/]
3. On page 4 of the form add alternativePaymentMethod='true' PaymentMethodId='PaymentMethod' to 'FormPayment' cpScript
4. Ecommerce > Cart > Summary > SummaryHeaderContent add PaymentMethodId='PaymentMethod' to 'FormPayment' cpScript
FormPayment
This script will display FormPayment form and posses the payment based on the data id parameter which should match data id of the record in Ecommerce > Merchants module.
[cp:literal:scripting key='FormPayment' dataid='DataId_Ecommerce_Merchants_Module' stage='summary' alternativePaymentMethod='true' PaymentMethodId='PaymentMethod' FormPaymentPreview='true' /]
| Property |
Description |
| dataid |
data id of the record in Ecommerce > Merchants module |
| stage |
stage of the script. supported values are: form or summary. |
| alternativePaymentMethod |
optional. true, false. default false. If form payment supports alternative Payment Method like e-check or Purchase Order. Custom set-up required. |
| PaymentMethodId |
optional. works with alternativePaymentMethod. takes id of the control which defined all Payment Methods. |
| FormPaymentPreview |
optional. default value is false. if set to true then payment information will be stored in the form and available in emails or completed page.
The card number will only display last 4 characters of the Credit Card.
NameOnCard: [cp:literal:scripting key='FormState' id='FormPayment_NameOnCard' /]
CardNumber: [cp:literal:scripting key='FormState' id='FormPayment_CardNumber' /]
CardType:[cp:literal:scripting key='FormState' id='FormPayment_CardType' /]
CardExpiration:[cp:literal:scripting key='FormState' id='FormPayment_CardExpiration' /]
|