Page 1 of 1

Modal/Popup of checkout Module

Posted: Sat Apr 13, 2024 5:19 am
by Portman
Hi,

If I was creating a new Module for Shipping or Payment or whatever and I wanted the Title of the Module to have a Modal Pop-up link in it - would that be possible? I can't get my head around how I would go about doing it,

for example, in a shipping module I have this code;

Code: Select all

      $this->quotes = [
        'id' => $this->code,
        'module' => MODULE_SHIPPING_POSTSTANDARD_TEXT_TITLE,
        'methods' => [[
          'id' => $this->code,
          'title' => $shipping_method,
          'cost' => $shipping_cost,
        ]],
      ];


and I want MODULE_SHIPPING_POSTSTANDARD_TEXT_TITLE to include a modal link ...

Code: Select all

const MODULE_SHIPPING_POSTSTANDARD_TEXT_TITLE = 'Standard Post <a href ="standardpost.php"><i class="fas fa-question-circle">';
right now it set up as a hyper link that opens and info page standardpost.php - I would much prefer a modal rather than customer being taken away from the shipping page... a modal obviously takes a bit more code and I'm not sure where I would put that code - if at all.

Re: Modal/Popup of checkout Module

Posted: Sat Apr 13, 2024 8:05 am
by heatherbell
Perhaps look at how the core customer data MATC module handles it?

Re: Modal/Popup of checkout Module

Posted: Mon Apr 15, 2024 11:50 am
by Portman
Ha ha... thanks I never even noticed that they were modal links - I never clicked on them....

I have got it to work, sort of...

so using the above example I have done this;
I have added this to my standard post module;

Code: Select all

    public function display_input() {	

      $p_modal = info_pages::get_page([
        'p.slug' => 'privacy',
        'pd.languages_id' => $_SESSION['languages_id'],
      ]);
      $modal = [
        'name' => 'PModal',
        'title' => $p_modal['pages_title'],
        'text' => $p_modal['pages_text'],
        'close_button' => MODULE_SHIPPING_POSTSTANDARD_CLOSE,
      ];

      ob_start();
      include Guarantor::ensure_global('Template')->map('modal.php', 'component');

      $GLOBALS['Template']->add_block(ob_get_clean(), 'footer_scripts');

	}
and changed by text file as follows

Code: Select all

const MODULE_SHIPPING_POSTSTANDARD_TEXT_TITLE = 'Standard Post <a href="#" role="button" class="card-link ml-0 border-bottom border-primary" data-toggle="modal" data-target="#PModal"><i class="fas fa-question-circle">';
this obviously opens the privacy policy page - so I want it to oper another page....

I created a new page in tools -> info pages
I named is: Standard Post - with the slug "standard" and change the code as follows;

Code: Select all

    public function display_input() {	

      $sp_modal = info_pages::get_page([
        'p.slug' => 'standard',
        'pd.languages_id' => $_SESSION['languages_id'],
      ]);
      $modal = [
        'name' => 'SPModal',
        'title' => $sp_modal['pages_title'],
        'text' => $sp_modal['pages_text'],
        'close_button' => MODULE_SHIPPING_POSTSTANDARD_CLOSE,
      ];

      ob_start();
      include Guarantor::ensure_global('Template')->map('modal.php', 'component');

      $GLOBALS['Template']->add_block(ob_get_clean(), 'footer_scripts');

	}

Code: Select all

const MODULE_SHIPPING_POSTSTANDARD_TEXT_TITLE = 'Standard Post <a href="#" role="button" class="card-link ml-0 border-bottom border-primary" data-toggle="modal" data-target="#SPModal"><i class="fas fa-question-circle">';
after doing this, nothing opens .... so I am obviously missing a step or 2, any idea what I have to do?