Is there a way to overwrite a function like zen_get_buy_now_button? Do I copy the function into an extra file with the same name or a different name?
Is there a way to overwrite a function like zen_get_buy_now_button? Do I copy the function into an extra file with the same name or a different name?
No there are no overrides for functions ... you would need to customize the original file ... save a copy of the original and your changed file for comparisons to future upgrades ...
Linda McGrath
If you have to think ... you haven't been zenned ...
Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!
Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.1]
Officially PayPal-Certified! Just click here
Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Just like everything else in Zen Cart, where there's a will there's a way! I've used the method I'll describe for a while now, based on a post that I found once and can't resurrect. It's a bit convoluted, but it does provide an override mechanism.
The function zen_get_buy_now_button exists in functions_general.php.
Step 1: Copy /includes/init_includes/init_general_functions.php to /includes/init_includes/overrides/init_general_functions.php. Edit that file
Step 2: Create the directory /includes/functions/overrides. Copy /includes/functions/functions_general.php into that folder and edit it to your heart's content.Code:<?php /** * load the system wide functions * see {@link http://www.zen-cart.com/wiki/index.php/Developers_API_Tutorials#InitSystem wikitutorials} for more details. * * @package initSystem * @copyright Copyright 2003-2005 Zen Cart Development Team * @copyright Portions Copyright 2003 osCommerce * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0 * @version $Id: init_general_funcs.php 2845 2006-01-13 06:49:15Z drbyte $ */ if (!defined('IS_ADMIN_FLAG')) { die('Illegal Access'); } /** * General Functions */ require(DIR_WS_FUNCTIONS . 'overrides/functions_general.php'); /** * html_output functions (href_links, input types etc) */ require(DIR_WS_FUNCTIONS . 'html_output.php'); /** * basic email functions */ require(DIR_WS_FUNCTIONS . 'functions_email.php'); /** * EZ-Pages functions */ require(DIR_WS_FUNCTIONS . 'functions_ezpages.php'); /** * User Defined Functions */ include(DIR_WS_MODULES . 'extra_functions.php'); ?>
The other functions can be overridden in a similar manner.
Just remember that if you do that, your alterations are NOT multi-version friendly. So will absolutely require changes when a new version is released, to ensure compatibility.
And they're not compatible with other overrides done by the storeowner, if they've already created an override for init_general_functions
.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donations always welcome: www.zen-cart.com/donate
Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.
Bookmarks