/
CartBonus (optional)

CartBonus (optional)

https://github.com/magesuite/cart-bonus

This module creates bonuses visible in the cart The feature is actually a cart price rule which can be triggered under certain conditions. On the storefront the user will notice a progress bar that hints at a potential bonus when meeting a subtotal threshold.

 

Installation

This module is optional

composer require "creativestyle/magesuite-cart-bonus" ^1.0.0

User manual

3.3. Cart Bonus

Admin settings

To add a cart bonus a new sales rule should be created in Marketing -> Promotions -> Cart price rules

The rule must be set as No coupon

In the Cart bonuses tab, a rule can be cart-bonus It is also possible to hide the rule label in order to make it a surprise for a user.

Free shipping rule is set as a cart bonus with a hidden label. The label is visible when a user passes the threshold.

Backend

Template

app/design/frontend/creativestyle/theme-creativeshop/MageSuite_CartBonus/templates/status.phtml
<?php /** @var $block \Creativestyle\CartBonusExtension\Block\Status */ $status = $block->getBonusesStatus(); $progressToNextBonusPercentage = $status->getProgressPercentage(); $amountToNextLevel = $status->getRemainingAmountForNextBonusWithCurrency(); $awardedBonusesCount = $status->getAwardedBonusesCount(); $allBonusesCount = $status->getBonusesCount(); $isFirstNotAwarded = true; $tooltipLeftLimit = $this->getTooltipLeftLimit(); $tooltipRightLimit = $this->getTooltipRightLimit(); .........

 

Block

vendor/creativestyle/magesuite-cart-bonus/Block/Status.php:32
class Status extends \Magento\Framework\View\Element\Template { public function getBonusesStatus() { $totals = $this->cart->getQuote()->getTotals(); $currentCartValue = $totals['subtotal']['value']; return $this->statusBuilder->build($currentCartValue); } }

Service

vendor/creativestyle/magesuite-cart-bonus/Service/StatusBuilder.php:51

 

Model

vendor/creativestyle/magesuite-cart-bonus/Model/Bonus/Status.php:34

 

Plugin

vendor/creativestyle/magesuite-shipping-addons/Plugin/Checkout/Block/Cart/Totals/AddFreeShippingBarVariables.php:40

 

Frontend

Each bonus is displayed as a section of a bar. After cart page is loaded the progress bar is animated.

PHTML template

The PHTML template is placed in theme-creativeshop/src/MageSuite_CartBonus/templates/status.phtml

It is possible to pass some configuration from the layout - theme-creativeshop/src/MageSuite_CartBonus/layout/default.xml

Also, paths or configurations for the following icons can be adjusted:

  • bonus.gift.icon.headline

  • bonus.gift.icon.gift

  • bonus.gift.icon.status

Styling

The styling for this component is provided by default in theme-cerativeshop. Styles are placed in components/cart/cart-bonus file.

 

Related content

3.3. Cart Bonus
3.3. Cart Bonus
More like this
CatalogProductListingCompatibility (optional)
CatalogProductListingCompatibility (optional)
Read with this
3.4.4. Free Shipping Indicator
3.4.4. Free Shipping Indicator
More like this
Instant purchase (optional)
Instant purchase (optional)
Read with this
DisableStockReservation (optional)
DisableStockReservation (optional)
Read with this