ecommerce_buy_now

This component renders an anchor element allowing the javascript function to add the item to the shopping cart and then proceeding directly to the shopping cart page.

{% component type: "ecommerce_buy_now", itemId: "<Item ID>" %}

Parameters and Options

Parameter Values Required Description
type ecommerce_buy_now

This is the name of the entity that needs to be used for the component retrieving function.

itemId <Item ID> The module item ID (specific Product) the data is to be sourced from
layout <Your Layout name>
Path to file that will contain the Liquid layout content to be parsed.

If an empty string, nothing will be rendered.
If paramater is not included, the default virtual layout will be rendered (see below).

collectionVariable <yourLiquidVariableName>
Assigns the data to a Liquid collection enabling further access to the data on the Page or Template using Liquid.

Your collectionVariable value must only contain English letters, numbers or underscores. Spaces or special characters are not supported.

Liquid Output

The below example shows the output data for the specified item ID. The Liquid data output from this example would look like the following (for example, when using a collectionVariable to create the collection):

{
  "Id": "2535",
  "Url": "/catalogs/demo-product-1",
  "ParentId": "2489",
  "LastUpdatedDate": "5/20/2020 9:35:15 AM",
  "Name": "DEMO Product 1",
  "UrlSlug": "demo-product-1",
  "Enabled": "True",
  "ReleaseDate": "5/5/2020 12:00:00 AM",
  "ExpiryDate": "12/11/2099 1:00:00 PM",
  "Weighting": "0",
  "Description": "<p>Sample product 1 for the ecommerce store.</p>",
  "ItemTags": "",
  "Author_Name": "",
  "Author_Url": "",
  "Author": "",
  "SEOTitle": "",
  "MetaTitle": "",
  "MetaDescription": "",
  "ShowPageForSearchEngine": "False",
  "CanonicalLink": "",
  "EnableAMP": "False",
  "AMPContent": "",
  "CodeEditor": "False",
  "ExternalId": "0",
  "SocialMetaTags": "",
  "OpenGraphProperties": "",
  "DisableForSiteSearch": "False",
  "SeoPriority": "0.5",
  "CreatedByMemberId": "0",
  "ItemCategories": "",
  "ItemCategoryIdList": "",
  "SKUCode": "DEMO1",
  "SiteSearchKeywords": "",
  "SmallImage": "/images/template-detail-dinewine-mobile@2x.png",
  "LargeImage": "/images/template-detail-dinewine-desktop@2x.jpg",
  "OnSale": "False",
  "IsGiftVoucher": "False",
  "ProductWeight": "0",
  "ProductWidth": "0",
  "ProductHeight": "0",
  "ProductDepth": "0",
  "EnableDropShipping": "False",
  "Supplier": "0",
  "UnitType": "",
  "MinimumUnits": "0",
  "MaximumUnits": "0",
  "RecurringType": "",
  "IsShippable": "True",
  "IsDownloadable": "False",
  "DownloadableFileLink": "",
  "NumberOfPossibleDownloads": "0",
  "taxRate": "0.0400",
  "Price": "39.9500",
  "IsHide": "False",
  "InStock": "0",
  "IsDisable": "False",
  "priceWithTax": "41.54800000",
  "ProductDataJSON": {
  "itemId": 2535,
  "attributes": {
    "12462596046050033665": {
      "id": "12462596046050033665",
      "isInventory": true,
      "name": "Size",
      "type": 2,
      "required": true,
      "optionIds": [
        "16234894512508370945",
        "16234894512508370946",
        "16234894512508370947"
      ]
    }
  },
  "variations": null,
  "options": {
    "16234894512508370945": {
      "id": "16234894512508370945",
      "attributeId": "12462596046050033665",
      "name": "Small",
      "image": "/images/template-detail-crafter-mobile.png",
      "price": 0.0000
    },
    "16234894512508370946": {
      "id": "16234894512508370946",
      "attributeId": "12462596046050033665",
      "name": "Medium",
      "image": "/images/template-crafter@2x.jpg",
      "price": 2.0000
    },
    "16234894512508370947": {
      "id": "16234894512508370947",
      "attributeId": "12462596046050033665",
      "name": "Large",
      "image": "/images/template-detail-crafter-desktop@2x.jpg",
      "price": 4.0000
    }
  },
  "inStockTotal": null,
  "recommendedPrice": 49.9500,
  "prices": {
    "0": 39.9500
  },
  "taxInPercent": 4.0000,
  "taxRate": 0.0400,
  "enablePreOrder": true,
  "maximumUnits": 0,
  "minimumUnits": 0,
  "QuantityThreshold": [
    {
      "Quantity": 0,
      "Price": 39.9500
    }
  ]
},
  "RecommendedPrice": "49.9500",
  "EnableInventoryControl": "False",
  "VolumeDiscount": [
  {
    "Quantity": 0,
    "Price": 39.9500
  }
],
  "PriceHtml": "<span data-cms_product_data_price=\"2535\">39.95</span>",
  "InStockHtml": "<span data-cms_product_data_in_stock=\"2535\">0</span>",
  "priceWithTaxHtml": "<span data-cms_product_data_price_with_tax=\"2535\">41.55</span>",
  "RecommendedPriceHtml": "<span data-cms_product_data_recommended_price=\"2535\">49.95</span>",
  "InventoryProductVariations": [
  {
    "SKUCode": "DEMO1",
    "InStock": 0,
    "PreOrder": 0
  }
],
  "ProductDataJsonHTML": "<script>initEcommerceProductPriceVariations(2535,{\"itemId\":2535,\"attributes\":{\"12462596046050033665\":{\"id\":\"12462596046050033665\",\"isInventory\":true,\"name\":\"Size\",\"type\":2,\"required\":true,\"optionIds\":[\"16234894512508370945\",\"16234894512508370946\",\"16234894512508370947\"]}},\"variations\":null,\"options\":{\"16234894512508370945\":{\"id\":\"16234894512508370945\",\"attributeId\":\"12462596046050033665\",\"name\":\"Small\",\"image\":\"/images/template-detail-crafter-mobile.png\",\"price\":0.0000},\"16234894512508370946\":{\"id\":\"16234894512508370946\",\"attributeId\":\"12462596046050033665\",\"name\":\"Medium\",\"image\":\"/images/template-crafter@2x.jpg\",\"price\":2.0000},\"16234894512508370947\":{\"id\":\"16234894512508370947\",\"attributeId\":\"12462596046050033665\",\"name\":\"Large\",\"image\":\"/images/template-detail-crafter-desktop@2x.jpg\",\"price\":4.0000}},\"inStockTotal\":null,\"recommendedPrice\":49.9500,\"prices\":{\"0\":39.9500},\"taxInPercent\":4.0000,\"taxRate\":0.0400,\"enablePreOrder\":true,\"maximumUnits\":0,\"minimumUnits\":0,\"QuantityThreshold\":[{\"Quantity\":0,\"Price\":39.9500}]});</script>",
  "Params": {}
}

Virtual Layout

If not using any custom layout or collection, the default virtual layout will output as follows:

<a href="javascript:" data-ecommerce_buy_now_Item="{{this.id}}" class="ecommerceBuyNow_Item system_button">Buy Now</a>

Accessing the Data

This data is also accessible directly on the Page or Template via a Liquid Collection by adding collectionVariable to the Component.

An example using collectionVariable with value "buynowCollection":

{% component type: "ecommerce_buy_now", itemId: "2535", collectionVariable: "buynowCollection" %}

Accessing the name of the item, which in our example would render the value DEMO Product 1

{{buynowCollection['name']}}


Related Articles

  • Payment Settings
  • Orders
  • {{ order }} object
    This liquid object will output the order details of a submitted payment. {% capture data...
  • module (Catalogs)
    This module component fetches data relating to eCommerce Catalogs and can be used to render Catalog structures and Products within them.
  • module (Products)
    This module component fetches data relating to eCommerce Products and can be used to render Product information.
  • ecommerce_add_to_cart
    This component renders an anchor element allowing the javascript function to add the item to the shopping cart.
  • ecommerce_item_quantity
    This component renders a form input element allowing a quantity to be set for when the source item is added to the shopping cart.
  • item_attributes
    This component fetches all attributes/options for a specified product. By default, each attribute group is rendered, with its options and any prices, according to their specified form inputs.
  • related_items
    This component fetches related items of a specific source item, such as a Product that has had Related Products assign to it.
  • grouped_items
    This component fetches grouped items of a specific source item, such as a Product that has been Grouped with other Products and allows the ability to navigate between grouped items.
  • currencies
    This component renders a form select element of all currency names, codes and symbols by default, and can also be used to output currency data to a Liquid collection.
  • shopping_cart
    This component fetches data relating to the shopping cart, such as any products added, order totals, tax, shipping, etc.
  • shipping_options
    This component renders a form select element of all shipping options configured on the site, and can also be used to output shipping option data to a Liquid collection.
  • tax_codes
    This component renders a form select element of all tax codes configured on the site, and can also be used to output tax code data to a Liquid collection.
  • payment_form_fields
    This component is used to render payment fields, and payment related validation errors, within a form using the capabilities provided by your configured payment gateway.
  • orders
    This component fetches Orders from the CRM, either owned by the logged-in user or for all customer Orders.
  • Getting Started
    With the recent release of eCommerce features there are some advanced system components that are...
  • Products
    Products are one of the most powerful and flexible modules in Treepl CMS. Create customised product schemas with multiple price points, catalogs, inventory tracked attributes/variables, SEO optimisation and more.
  • Catalogs
    When organising any eCommerce store, Catalogs are crucial to your Products structure and browserbility. Easily create and customise unlimited product catalogs for your online store.
  • countries
    This component renders a form select element of all country names and country codes by default, and can also be used to output country codes/names to a Liquid collection.
  • domain_settings
    This module component retrieves settings associated with the current domain, or optionally from another specified domain configured in the site instance.

External Resources

There are currently no external resources available.

Please let us know if you have any other contributions or know of any helpful resources you'd like to see added here.


Questions?

We are always happy to help with any questions you may have.
Send us a message at support@treepl.co and we will consult you as soon as possible.