- Introduction
- Requirements
- Installation
- Configuration
- Usage
- Customization
- Maintainers
Commerce Promo Bar allows stores to display notifications and promotional information via the bar on top pages or any positions.
This module requires Drupal Commerce 2, and it's submodule promotion and Color field module.
Install the Commerce Promo Bar module as you would normally install any Drupal contrib module. Visit https://www.drupal.org/node/1897420 for further information.
1. Navigate to Administration > Extend and enable the Commerce Promo Bar
module.
2. Navigate to Home > Administration > Structure > Block layout and
place Commerce Promo Bar block onto region where you want to show promo bars.
(if you want to show only one promo bar always - uncheck Stack promo bars)
3. Navigate to Home > Administration > Commerce > Configuration > Promo Bar.
if you want to add fields, or change display & form view modes.
1. Navigate to Home > Administration > Commerce > Promo Bars
where you can create new promo bar.
2. Promo bar should be visible on region where you placed block from
2nd step from Configuration.
- adjust background color
- adjust text color
- use tokens inside promo bar body
- WYSIWYG editor to style promo bar message
- set start and end date
- set countdown date and display countdown timer
- restrict visibility per store
- restrict visibility per customer role
- restrict visibility per country (show or hide for the listed countries)
- restrict visibility per any path
- If you want to use Twig, use
commerce-promo-bar.html.twigfor any changes. - If you want to use UI for changes, it is possible trough WYSIWYG editor and/or view mode / field formatters to achieve some customizations.
- Promo Bar entity is field-able, so you can add any field to the entity. To use it within Promo Bar body, insert them with tokens
The rules the block uses are available to API resources and other front ends:
PromoBarStorageInterface::loadVisible($store, $account, $path, $cacheability)returns the promo bars visible to a customer on a page: available for the store, customer roles and country, filtered byFilterPromoBarsEvent, then by page visibility. Pass the front-end page path, or NULL for the current request path. The cacheability collects the cache tags, contexts and the max-age until the next scheduled change.commerce_promo_bar.visibilitychecks the page visibility of one promo bar for a path.commerce_promo_bar.body_processorreturns the body with tokens replaced and the text format applied, for output that does not render the entity.FilterPromoBarsEventsubscribers get the path and the customer throughgetPath()andgetAccount(), and add their cache contexts togetCacheability().
NOTES:
The country is the one Commerce resolves for the current request
(commerce.current_country). Without a country resolver of your own, that
is the current store's country, then the site's default country. To use the
customer's location, add a service tagged commerce.country_resolver, for
example one that reads a CDN country header or GeoIP.
Javascript which provides functionality for countdown timer expects
existence of class promo-bar-countdown-1 where number 1 from example
represents promo bar entity ID.
Color fields which are used for customization of color for background and text
expects existence of class article.promo-bar-wrapper-1
where number 1 from example represents promo bar entity ID.
The 1.0.x branch was created by:
- Valentino Medimorec (valic) - https://www.drupal.org/u/valic
Project page: https://www.drupal.org/project/commerce_promo_bar
