24/7 Support - 800.608.6482

Miva Merchant Community Forums

  1. #1
    Join Date
    Feb 2009
    Location
    CO, US
    Posts
    9

    Question How to alter module priority

    I'm working on module which generates the coupon code in its 'fulfill' feature. Everything works beautifully but my plan was to send the coupon code to the customer in the order confirmation email which is generated by another module's 'fulfill' feature.

    In the sources for miva I didn't find the implementation for StoreModuleList_Load_Feature function, so I poked around the database structure in hopes of finding anything that would control the priority for modules so they're called in a particular order (i.e. first the coupon is created then email is sent). No luck there.

    My ideas at this point are (in order of increasing awkwardness):
    - implement coupon generation as log feature hooked to 'AUTH' Action
    - uninstall email module and re-install it again so it is picked after my module in unsorted result
    - implement coupon generation in component call referenced in email template

    Do I have any less hack-y options at this time?

  2. #2
    Join Date
    Feb 2009
    Location
    CO, US
    Posts
    9

    Default Re: How to alter module priority

    Well, first workaround is out of the window. According to sources log feature is called after fulfill.

  3. #3
    Join Date
    Feb 2009
    Location
    CO, US
    Posts
    9

    Default Re: How to alter module priority

    Found unused module_id lower than email module and after thorough review to make sure it's not used anywhere else pulled heart-stopping trick:

    UPDATE `Modules` SET `id` = 240 WHERE `id` = 258;
    UPDATE `ModuleXFeature` SET `module_id` = 240 WHERE `module_id` = 258;
    UPDATE `s01_Items` SET `module_id` = 240 WHERE `module_id` = 258;
    UPDATE `s01_StoreModules` SET `module_id` = 240 WHERE `module_id` = 258;

    Other tables referencing module_ids (charges, shipping etc) were not involved in my case.
    Now modules are called in the order I need.

    Don't try this at home! Not proud of what I had to do. Miva should really add `call_order` in `s01_StoreModules` and sort by that column in StoreModuleList_Load_Feature

  4. #4
    Join Date
    Mar 2006
    Posts
    1,869

    Default Re: How to alter module priority

    It does seem odd that the LSK doesn't contain any of the Module or StoreModule functions. Weren't they in there at one time?

    Tigra, could you put your coupon-generation code in a system action, instead of a log action? The possible downside of that is that the code will get run as soon as customer tries to check out, even though they might get stopped by a problem such as a declined credit card. Sometimes you can use a combination of system and log action to cover all the possibilities.

    HTH --
    Kent Multer
    Magic Metal Productions
    http://TheMagicM.com
    * Web developer/designer
    * E-commerce and Miva
    * Author, The Official Miva Web Scripting Book -- available on-line:
    http://www.amazon.com/exec/obidos/IS...icmetalproducA

  5. #5
    Join Date
    Mar 2006
    Posts
    11,180

    Default Re: How to alter module priority

    The best way to do this is with a token in the email template. My coupon module does this in thousands of stores. You can wrap the generation token with a conditional to only do it when one of the actions is AUTH if the store has a re-send email feature. Now if you are doing this for your store only you could modify the order of the module IDs, but you would not want to do that to other stores which might get your module.

  6. #6
    Join Date
    Feb 2009
    Location
    CO, US
    Posts
    9

    Default Re: How to alter module priority

    Thanks for your reply.
    My code is intended for one store deployment, thus module ID based solution.
    I would probably resort to using component token otherwise as you suggested.
    What would like to see is this issue put to rest at the system level.
    There's even existing (although not the most elegant) interface for reordering records - for example in product attributes.

  7. #7
    Join Date
    Feb 2009
    Location
    CO, US
    Posts
    9

    Default Re: How to alter module priority

    That's an option. Thanks for the idea. If similar situation arises I'll just make as separate action for it and add it to the list after AUTH. This way if there are other modules hooked to AUTH I don't have to deal with random call order again. According to source the Actions are processed in the order they're listed.

    Quote Originally Posted by Kent Multer View Post

    Tigra, could you put your coupon-generation code in a system action, instead of a log action? ...

Posting Rules

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •