Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Can I HOOK?


LeeFoster

Recommended Posts

Hi all,

Can I Hook in the way below or is it not possible?

switch ($page) {

	case 'checkout_confirmation' :
      include ('includes/modules/header_tags/customer_service/modules/page/cs_checkout_confirmation.php');
      break;

    case 'checkout_payment' :
      include ('includes/modules/header_tags/customer_service/modules/page/cs_checkout_payment.php');
      break;

    case 'checkout_payment_address' :
      include ('includes/modules/header_tags/customer_service/modules/page/cs_checkout_payment_address.php');
      break;

    case 'checkout_shipping' :
      include ('includes/modules/header_tags/customer_service/modules/page/cs_checkout_shipping.php');
      break;

    case 'checkout_shipping_address' :
      include ('includes/modules/header_tags/customer_service/modules/page/cs_checkout_shipping_address.php');
      break;

    case 'create_account' :
      include ('includes/modules/header_tags/customer_service/modules/page/cs_create_account.php');
      break; 

    case 'shopping_cart' :
      include ('includes/modules/header_tags/customer_service/modules/page/cs_add_2_cart.php');
      break;
	  
echo $OSCOM_Hooks->call('siteWide', 'injectCSPage');

  }

And the content I'm trying to hook in

class hook_shop_siteWide_csTicketPage {
  var $version = '1.0.0';
  
  function listen_injectCSPage() {
    
    $csPage =  'case "ticket" : include ("includes/modules/header_tags/customer_service/modules/page/cs_ticket.php");
      break;'; 

    return $csPage;
  }


}

 

Link to comment
Share on other sites

No. 

You can't inject PHP via hooks.  You can only generate HTML.  So

    $csPage =  'case "ticket" : include ("includes/modules/header_tags/customer_service/modules/page/cs_ticket.php");
      break;';

won't work. 

I have code for doing something similar that I just haven't released yet.  No time right now, but I could post it later.  It would basically make the hook call look like

foreach ($OSCOM_Hooks->generate('siteWide', 'injectCSPage', [ 'page' => $page ]) as $include) {
  include $include;
}

 

Always back up before making changes.

Link to comment
Share on other sites

8 minutes ago, ecartz said:

No. 

You can't inject PHP via hooks.  You can only generate HTML.  So


    $csPage =  'case "ticket" : include ("includes/modules/header_tags/customer_service/modules/page/cs_ticket.php");
      break;';

won't work. 

I have code for doing something similar that I just haven't released yet.  No time right now, but I could post it later.  It would basically make the hook call look like


foreach ($OSCOM_Hooks->generate('siteWide', 'injectCSPage', [ 'page' => $page ]) as $include) {
  include $include;
}

 

Thanks, I had another way to do it but wanted to know if this would work first.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...