Skip to content
rivoluzionif

PrestaShop module · Open source · Demo project

rfshipbar

A real, installable module with an admin panel and live cart updates.

rfshipbar desktop rfshipbar mobile

The brief

Demo brief: a PrestaShop store wants to show customers how far they are from free shipping, everywhere on the site, updating in real time as the cart changes. Marketplace modules tried did not refresh in the AJAX modal.

Goals

  • Configurable threshold, multi-currency, tax included or excluded
  • Real-time update without page reload
  • Clean code, compatible with PrestaShop 1.7.6+ and 8.x, no core changes

What we built

  • rfshipbar module with configuration panel (HelperForm): threshold, messages, colour, position
  • Three hooks: cart, AJAX modal, header
  • JSON endpoint and script listening to PrestaShop's updatedCart event
  • Smarty template, dependency-free CSS and JS
  • MIT licence: download it, install it, look inside

Try it: change the cart and watch the bar

A piece of the code, for those who like to look inside

public function getBarData(Cart $cart = null)
{
    $cart = $cart ?: $this->context->cart;
    $taxIncl = (bool) Configuration::get(self::CONF_TAX_INCL);
    $total = $cart ? (float) $cart->getOrderTotal($taxIncl, Cart::ONLY_PRODUCTS) : 0.0;
    $threshold = Tools::convertPrice((float) Configuration::get(self::CONF_THRESHOLD), $this->context->currency);
    $missing = max(0, $threshold - $total);
    $percent = $threshold > 0 ? min(100, (int) round($total / $threshold * 100)) : 100;
    $msg = $missing > 0
        ? str_replace('{amount}', '<strong>' . Tools::displayPrice($missing) . '</strong>', Configuration::get(self::CONF_MSG_BEFORE))
        : Configuration::get(self::CONF_MSG_AFTER);
    return ['missing' => $missing, 'percent' => $percent, 'message' => $msg, 'unlocked' => $missing <= 0];
}

Demo project: company, people and data are fictional. The code and design are real.

Stop postponing. Let's talk about your project today.

Written quote within 24 hours. No commitment, no endless sales call: just a clear proposal with price and timeline.