Jump to content
Latest News: (loading..)

Recommended Posts

I'm not sure that general hooks serve for all needs of add-ons to call hooks in specific places.

Some files have several actions, some add-ons need to interfere before sql is executed, some after, some need to interfere in e-mail content etc.

 

Anyway maybe first we should define where in a file hooks should be used and where ht or content modules.

My opinion/suggestion:

1. between includes application_top.php and includes template_top.php => hooks

2. in template_top.php header tags are included and most things which can be done in that part and what can be done with the output in header area or footer area should be done with ht.

3. In the content/output part between include template_top.php and include template_bottom.php => content modules => they are more flexible, include config settings, language files, template file for output etc. I wouldn't use hooks in that part.

 

Share this post


Link to post
Share on other sites
Posted (edited)

@raiwa

We could discuss about places but I have to say that pre hard coded addons name using wont be prefered. Call it by functional place is more practic.

For example:

in checkout_confirmation page 'Matc'  is a readable but not pragmatic usage.

  echo $OSCOM_Hooks->call('checkout', 'Matc');


This is a typical 'Form' hook so it would be:

  echo $OSCOM_Hooks->call('checkout', 'Form');

and we could dropp a lot of checkout hooks into catalog/includeshooks/shop/checkout/ directory.

  • formMatch.php
  • formConfirmation.php
  • formChecker.php

Harald implement a general hooks group called 'global' so you dont have to call it in template_top even if it has a special reason.
 

Edited by tgely

:blink:
osCommerce based shop owner with minimal design and focused on background works. When the less is more.
Email managment with tracking pixel, package managment for shipping, stock management, warehouse managment with bar code reader, parcel shops management on 3000 pickup points without local store.

Share this post


Link to post
Share on other sites
Posted (edited)
22 hours ago, raiwa said:

Second level: add-on using the hook or hook task:

Example:


// POINTS REWARDS BS
    echo $OSCOM_Hooks->call('checkout_confirmation', 'CheckoutConfirmPoints');

Directory: includes/hooks/shop/checkout_confirmation/points.php


class hook_shop_checkout_confirmation_points {
...
  function listen_CheckoutConfirmPoints() {

 

@tgely, it seems there is a misunderstood, if you refer to the above, it was just an example how to apply the namespace.

My suggestion to add to core was only this part:

22 hours ago, raiwa said:

Suggestion for hooks:

generic hook registry in each main page or better in application top:


  $OSCOM_Hooks->register(strtok($PHP_SELF, '.'));

Requires namespace convention for first hook level: filename of main page without extension.

 

Edited by raiwa

Share this post


Link to post
Share on other sites
Posted (edited)

@raiwa

you are right with this general code
 

$OSCOM_Hooks->register(strtok($PHP_SELF, '.'));

and I partly agree with "CheckoutConfirmPoints". This could be pragmatical but very pointed name. This hook states that CheckoutConfirmation function should be there.
 

echo $OSCOM_Hooks->call('checkout_confirmation', 'CheckoutConfirmPoints');

checkout_confirmation explain the path but 'CheckoutConfirmPoints' maybe not referal the real hooked calls. There could be anyting else for example a html canvas, a video or checkbox hook. Its free and wont be predestinated so I suggested the code place name instead.

echo $OSCOM_Hooks->call('checkout_confirmation', 'FormBeforeConfirmationButton');

(Wordpress works by this way).

Edited by tgely
missed Button from context

:blink:
osCommerce based shop owner with minimal design and focused on background works. When the less is more.
Email managment with tracking pixel, package managment for shipping, stock management, warehouse managment with bar code reader, parcel shops management on 3000 pickup points without local store.

Share this post


Link to post
Share on other sites

I'm not sure if we need the generic hook calls at this point. This could be left to be done by the add-ons installation. A naming convention would be good to be defined.

The generic hook register woul be already a big step maybe together with a already created hook directory structure for the core pages.

Share this post


Link to post
Share on other sites

Another thought about the hook calls:

an installation function in core to add the hook call by auto file edit in the add-on installation script.

variables to pass to the function:

- filename

- hook name

- reference core line where to insert the hook call ( above/below)

have a look into the script used in the points and rewards add-on: ht-points_rewards.php

It adds and removes the hook registry and calls for all hooks in several core pages.

Of course it would need to be improved.

Requirement: no core file changes or at least following strict edit rules (blank lines etc)

 

 

Share this post


Link to post
Share on other sites

Other suggestion for hooks:

auto include language file if exists in includes/classes/hooks.php:

      if ( file_exists($directory) ) {
        if ( $dir = @dir($directory) ) {
          if ( file_exists('includes/languages/' . $language . '/hooks/' . $this->_site . '/' . $group) ) {
            include('includes/languages/' . $language . '/hooks/' . $this->_site . '/' . $group);
          }

          while ( $file = $dir->read() ) {

 

Share this post


Link to post
Share on other sites
19 hours ago, raiwa said:

an installation function in core to add the hook call by auto file edit in the add-on installation script.

variables to pass to the function:

- filename

- hook name

- reference core line where to insert the hook call ( above/below)

have a look into the script used in the points and rewards add-on: ht-points_rewards.php

It adds and removes the hook registry and calls for all hooks in several core pages.

Of course it would need to be improved.

If I understand this correctly, it sounds like an awesome idea.  Could it be a stand alone module to inject hooks or module calls without actually editing the core files --- at least until the core files are fully modularized?

Dan

 

Share this post


Link to post
Share on other sites
20 minutes ago, Dan Cole said:

Could it be a stand alone module to inject hooks or module calls without actually editing the core files --- at least until the core files are fully modularized?

On second thought, I guess it is not much different then editing the files themselves but it does make you wondered if we need to add any predefined hooks at all or whether Gary @burt can simply cross this issue off his path to final list and move on.

Dan

Share this post


Link to post
Share on other sites

The original ethos behind the hook system is to stop addon makers from forcing users to;

Find Line X in xyz.php
Add in 50 lines of code

Save

Instead, the Hook file has the 50 lines of code in it. And then addon maker says;

Upload Hook
Find Line X in xyz.php
Add 1 line of code

Save

 

I have zero plan to change any aspect of the Hook system.
I have zero plan to add in pre-placed hooks.

Anything that adds more work, I have no interest in taking on.  If that work gets done by someone else, is 100% fully bug free and tested, and is done at a clean Github...meaning all I have to do is press a button, I'm all for it.  Put bluntly;  I aint doing anything else.

 

 


This is a signature that appears on all my posts.  
IF YOU MAKE A POST REQUESTING HELP...please state the exact version
of osCommerce that you are using. THANKS

 
Get the latest current code (community-supported responsive 2.3.4.1BS Edge) here

 

Share this post


Link to post
Share on other sites

Anyone got comments on the index_products implementation?


For a new install or if your store isn't mobile-friendly, get the community-supported responsive osCommerce (2.3.4.1 CE) here: https://github.com/gburton/osCommerce-234-bootstrap/archive/master.zip

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Share this post


Link to post
Share on other sites
Posted (edited)
8 hours ago, burt said:

Upload Hook

Find Line X in xyz.php
Add 1 line of code

Right now it is "Add 2 lines of code": register hook and call hook.

With the following in application_top.php it would be 1 line:

$OSCOM_Hooks->register(strtok($PHP_SELF, '.'));

 

8 hours ago, burt said:

I have zero plan to change any aspect of the Hook system.

Why then should someone loose the time to create a pull request :sleep:

Edited by raiwa

Share this post


Link to post
Share on other sites

@burt you don't think it's confusing to have a module called cm_ip_category_description outputting a manufacturer description?


For a new install or if your store isn't mobile-friendly, get the community-supported responsive osCommerce (2.3.4.1 CE) here: https://github.com/gburton/osCommerce-234-bootstrap/archive/master.zip

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Share this post


Link to post
Share on other sites
1 hour ago, BrockleyJohn said:

Anyone got comments on the index_products implementation?

I have - doesn't work! PR in with fixes...


For a new install or if your store isn't mobile-friendly, get the community-supported responsive osCommerce (2.3.4.1 CE) here: https://github.com/gburton/osCommerce-234-bootstrap/archive/master.zip

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Share this post


Link to post
Share on other sites
2 hours ago, raiwa said:

Why then should someone loose the time to create a pull request :sleep:

And that, right there, is why it's taken over 4 years to get anywhere.


This is a signature that appears on all my posts.  
IF YOU MAKE A POST REQUESTING HELP...please state the exact version
of osCommerce that you are using. THANKS

 
Get the latest current code (community-supported responsive 2.3.4.1BS Edge) here

 

Share this post


Link to post
Share on other sites
2 hours ago, BrockleyJohn said:

@burt you don't think it's confusing to have a module called cm_ip_category_description outputting a manufacturer description?

Yep.

IIRC I renamed it prior to remembering that it is also used @ index-manufacturers :(

 


This is a signature that appears on all my posts.  
IF YOU MAKE A POST REQUESTING HELP...please state the exact version
of osCommerce that you are using. THANKS

 
Get the latest current code (community-supported responsive 2.3.4.1BS Edge) here

 

Share this post


Link to post
Share on other sites
1 hour ago, BrockleyJohn said:

I have - doesn't work! PR in with fixes...

I'm currently reviewing the original one.  I have some fixes and things in place...


This is a signature that appears on all my posts.  
IF YOU MAKE A POST REQUESTING HELP...please state the exact version
of osCommerce that you are using. THANKS

 
Get the latest current code (community-supported responsive 2.3.4.1BS Edge) here

 

Share this post


Link to post
Share on other sites
Posted (edited)

I took as much unpaid leave as I could in March to try to get to Final prior to the end of March, thank you to those few guys who bought into the 28d Project which allowed that :thumbsup: 

Unfortunately I was unable to get to a Finalised release inside the March timeframe.  But it is close.

Product Class did not make it :(
Category Class did :)  
Lots of things updated and renamed.

I need to fix a few modules, then I will push what has been done to Master and will call it final.

After that, it's the end of the Community Version in terms of coding, as coders prefer to start their own splinter projects rather than help to get this version Final.  

 

Edited by burt

This is a signature that appears on all my posts.  
IF YOU MAKE A POST REQUESTING HELP...please state the exact version
of osCommerce that you are using. THANKS

 
Get the latest current code (community-supported responsive 2.3.4.1BS Edge) here

 

Share this post


Link to post
Share on other sites
7 minutes ago, burt said:

After that, it's the end of the Community Version in terms of coding, as coders prefer to start their own splinter projects rather than help to get this version Final.

What a pity. I can only see it causing confusion to shop owners with all the different versions and no official version to use that is any good.

Gary - Thanks for what you have done.


REMEMBER BACKUP, BACKUP AND BACKUP

Before installing the official version of oscommerce first look at a responsive version here

It's very easy to over complicate what are simple things in life

Share this post


Link to post
Share on other sites
On 14/3/2018 at 3:36 PM, burt said:

5. getContent calls
DISCUSSION

  • Discussion needed

If the modular shopping cart is discarted and I suppose the modular checkout will be late or not planned to be included, the following calls should be considered:

  • shopping cart: between alternative checkout section and closing </form>
  • checkout shipping and payment above or below comments
  • checkout confirmation before confirm order button
  • product reviews and reviews write: at the bottom of main content
  • create account: before continue button (not sure if needed)

 

Share this post


Link to post
Share on other sites
Just now, raiwa said:
  • shopping cart: between alternative checkout section and closing </form>
  • checkout shipping and payment above or below comments
  • checkout confirmation before confirm order button
  • product reviews and reviews write: at the bottom of main content
  • create account: before continue button (not sure if needed)

What is the reasoning for these?


This is a signature that appears on all my posts.  
IF YOU MAKE A POST REQUESTING HELP...please state the exact version
of osCommerce that you are using. THANKS

 
Get the latest current code (community-supported responsive 2.3.4.1BS Edge) here

 

Share this post


Link to post
Share on other sites

There are many addons out already which use content modules or could be changed to use content modules instead of hook or ht in these pages:

shopping cart: continue shopping, shipping estimator, recently viewed products, related products...

checkout payment: discount code, points and rewards, matc

checkout confirmation: matc

create account: recaptcha

contact us: (just remembered): recaptcha

...

I believe it wouldn't do any harm but help add-on coders and store owners

Share this post


Link to post
Share on other sites

I don't see much point in adding getContent calls unless the page is full modularised.  It might as well be up to the individual addon maker to provide an instruction and up to the individual shopowner to copy/paste a line of code.


This is a signature that appears on all my posts.  
IF YOU MAKE A POST REQUESTING HELP...please state the exact version
of osCommerce that you are using. THANKS

 
Get the latest current code (community-supported responsive 2.3.4.1BS Edge) here

 

Share this post


Link to post
Share on other sites
10 minutes ago, burt said:

I don't see much point in adding getContent calls unless the page is full modularised.

It is (was) done like this in product info since years

10 minutes ago, burt said:

 It might as well be up to the individual addon maker to provide an instruction and up to the individual shopowner to copy/paste a line of code.

It's just this: add one line to core file and install module versus install one module and not any file change

Full modular shopping cart exists since years, see also

https://forums.oscommerce.com/topic/412708-path-to-final/?do=findComment&comment=1767650

https://forums.oscommerce.com/topic/412708-path-to-final/?do=findComment&comment=1767662

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×