MMv4 KB
 
Custom Script Slots
  Last Edited - 01/19/2015 2:50pm PST
  Category Path - Developer's Guide > Document Structure
 
Modular Merchant's shopping cart software opens the door for customized functionality with its "custom script slots". Various sections of the software will check for the presence of a custom script file, and run any that are found. Custom script slots allow Modular Merchant developers to enhance your store so that it can interact with a third-party service, database or other system.

prerequisites
Access to the shopping cart's custom script slots requires:
1. The account must be on the Platinum plan or higher.
2. A file containing a Custom Script Authentication Key for the account (provided by Modular Merchant) must be installed. The cart will ignore any custom scripts that have been installed if the authentication key is not present.
 
Custom Scripting Policies

Custom scripts are developed by Modular Merchant as a custom programming project. Development of custom scripts by third party developers is not allowed.

Installation of or modification to custom scripts without prior evaluation of and approval by Modular Merchant will result in deletion of the account's custom scripts and authentication key, and a loss of future custom script privileges.
 
Custom Script Location

Any custom script being utilized should be uploaded to the store's cstm directory. If a valid Custom Script Authentication Key file has been installed, then the shopping cart software will look in this directory for any of the files listed below.

If a custom script slot isn't being used, it may safely be removed from the "cstm" directory. No errors will be generated if a custom script is deleted off the server.
 
Custom Script Slot Trigger Points

Several trigger points for custom scripts are available. More may be added in the future. The available trigger points include:

affiliate tracking id (tid) handler
File Name: affiliate_tid_handler.php
Run when a customer clicks on a link containing an Affilaite Tracking ID (TID) number. The custom script is run after the Affiliate Tracking cookie is set, and before the customer is redirected to the TID number's landing page.

delete unsubcribed items
File Name: delete_unsubscribed_items.php
Run when the software evaluates a customer subscription that has been set to "pending cancellation". Instead of processing the subscription, the cart will first run this custom script (if any) and then delete the customer's cancelled subscription.

post transaction
File Name: post_transaction.php
This script is triggered just after a transaction is recorded in the store's order records. It is run once per order. If the store is processing a series of subscriptions, it will be triggered once for each subscription that is successfully processed.

Post Transaction custom scripts commonly reference the SID number of the order that was just placed. This order SID number can be accessed in Post Transaction custom scripts in the variable:
$_SESSION[mmid()]['system']['post_transaction']['orders_id']

pre transaction
File Name: pre_transaction.php
This script is triggered immediately before a transaction is recorded in the store's order records. It is run once per order. If the store is processing a series of subscriptions, it will be triggered once for each subscription that is successfully processed.

product editor
File Name: product_editor.php
This script adds content to the very bottom of the Product Editor. It can be used to increase the number of options in the Editor. It is typically used to add fields used in integrating products with third-party software and systems.
Powered by ModularKB