Page 1 of 1

Show set amount for free shipping in Header

Posted: Sun Feb 13, 2022 7:33 pm
by Tanya
How to show the set amount with currency for free shipping in header? And the set amount change if customer change currencies in Navbar.

I have added the text message and I need to show the set amount with currency in the red rectangle.

Re: Show set amount for free shipping in Header

Posted: Sun Feb 13, 2022 9:18 pm
by ecartz

Code: Select all

MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER
If you want more help than that, we'd need to see the code that you are using to post the message.

Re: Show set amount for free shipping in Header

Posted: Tue Feb 15, 2022 8:46 am
by Tanya
@ecartz Now the amount for free shipping is showing but without currency. I would like to show with currency and convert the amount to whatever currency is selected.

The code that I used as below:

Main File: /includes/modules/content/header/cm_header_mond_ups.php

Code: Select all

class cm_header_mond_ups extends abstract_executable_module {

    const CONFIG_KEY_BASE = 'MODULE_CONTENT_HEADER_MOND_UPS_';

    public function __construct() {
      parent::__construct(__FILE__);
    }

    public function execute() {
      $tpl_data = [ 'group' => $this->group, 'file' => __FILE__ ];
      include 'includes/modules/content/cm_template.php';
    }

    protected function get_parameters() {
      return [
        'MODULE_CONTENT_HEADER_MOND_UPS_STATUS' => [
          'title' => 'Enable Header UPS Free Shipping Banner Module',
          'value' => 'True',
          'desc' => 'Do you want to enable the UPS Free Shipping Banner content module?',
          'set_func' => "Config::select_one(['True', 'False'], ",
        ],
        'MODULE_CONTENT_HEADER_MOND_UPS_CONTENT_WIDTH' => [
          'title' => 'Content Width',
          'value' => '4',
          'desc' => 'What width container should the content be shown in?',
          'set_func' => "Config::select_one(['12', '11', '10', '9', '8', '7', '6', '5', '4', '3', '2', '1'], ",
        ],
        'MODULE_CONTENT_HEADER_MOND_UPS_FREE_SHIPPING_OVER' => [
          'title' => 'Free Shipping For Orders Over',
          'value' => '50',
          'desc' => 'Provide free shipping for orders over the set amount.',
          'use_func' => 'currencies->format',
        ],
        'MODULE_CONTENT_HEADER_MOND_UPS_SORT_ORDER' => [
          'title' => 'Sort Order',
          'value' => '20',
          'desc' => 'Sort order of display. Lowest is displayed first.',
        ],
      ];
    }

  }
Template File: /includes/modules/content/header/templates/tpl_cm_header_mond_ups.php

Code: Select all

<div class="col-md-12 col-lg-6 col-xl-<?= (int)MODULE_CONTENT_HEADER_MOND_UPS_CONTENT_WIDTH ?> cm-header-ups" style="margin-bottom:8px; text-align:center;">
  <text style="display:inline-block; vertical-align:middle; text-align:center"><?=MODULE_CONTENT_HEADER_MOND_UPS_TEXT?>
  <?=MODULE_CONTENT_HEADER_MOND_UPS_FREE_SHIPPING_OVER?></text>
</div>
Languages File: /includes/languages/english/modules/content/header/cm_header_mond_ups.php

Code: Select all

  define('MODULE_CONTENT_HEADER_MOND_UPS_TITLE', 'Mond UPS Free Shipping Banner');
  define('MODULE_CONTENT_HEADER_MOND_UPS_DESCRIPTION', 'Adds UPS Free Shipping Banner into the Header Area of your site.');

  define('MODULE_CONTENT_HEADER_MOND_UPS_TEXT', '<b>FREE SHIPPING! </b><br>UPS Express on orders over');

Re: Show set amount for free shipping in Header

Posted: Tue Feb 15, 2022 9:54 am
by ecartz

Code: Select all

  const MODULE_CONTENT_HEADER_MOND_UPS_TEXT = '<b>FREE SHIPPING! </b><br>UPS Express on orders over %s';

Code: Select all

  <text style="display:inline-block; vertical-align:middle; text-align:center"><?=
    sprintf(MODULE_CONTENT_HEADER_MOND_UPS_TEXT, Guarantor::ensure_global('currencies')->format(MODULE_CONTENT_HEADER_MOND_UPS_FREE_SHIPPING_OVER))
  ?></text>
Note that that is changes in two different files.

Re: Show set amount for free shipping in Header

Posted: Tue Feb 15, 2022 8:09 pm
by Tanya
Thank you! It works!