Location for common store/admin defines?
Is there a file location for custom defines that are used on both the store side and admin? I've got the same defines in extra_definitions on both store and admin sides and it's a nightmare to remember to update both sides and a pain to code both files. I get fatal undefined constant errors for observers and other modules that execute from both the store and admin if a define is not on both sides. I'd really like to consolidate all my defines to make updating the constants and updating zc easier. Thanks!
Dave
zc157c, php 8.0.2
Re: Location for common store/admin defines?
Pull in the storefront file in admin; don't replicate it.
Example:
storefront: includes/functions/extra_functions/some_functions.php
Admin file admin/includes/functions/extra_functions/some_functions.php would be:
<?php
require DIR_FS_CATALOG . DIR_WS_FUNCTIONS . '/extra_functions/some_functions.php';
Re: Location for common store/admin defines?
Quote:
Originally Posted by
swguy
Pull in the storefront file in admin; don't replicate it.
Example:
storefront: includes/functions/extra_functions/some_functions.php
Admin file admin/includes/functions/extra_functions/some_functions.php would be:
<?php
require DIR_FS_CATALOG . DIR_WS_FUNCTIONS . '/extra_functions/some_functions.php';
Understanding that by use of that file path the catalog file must be completely in the catalog fileset and not in the (current) zc_plugins architecture.
Re: Location for common store/admin defines?
Thanks, that's very helpful. How would I access admin files from the store-side? DIR_FS_ADMIN does not appear to be present on the store-side.
Thank you!
Re: Location for common store/admin defines?
You can't access admin files from the store side unless you hardcode the admin name somewhere, which is not recommended.
Put things on the storefront and then pull them into admin using the technique from above.
Re: Location for common store/admin defines?
Quote:
Originally Posted by
Dave224
Thanks, that's very helpful. How would I access admin files from the store-side? DIR_FS_ADMIN does not appear to be present on the store-side.
Thank you!
Put another way, for what intentional purpose would the catalog side need to access the admin?
Re: Location for common store/admin defines?
I thought so swguy. What I'm trying to do is create and mail an invoice to customers who use the invoice payment method, currently restricted to selected customers, when they checkout. The invoice code (and constants) are on the admin side. To complicate matters, the invoice code requires a stock by attribute file, also on the admin side. I think I need to trigger this process from the admin side using a cron job. Ugh. Any other suggestions?
Dave
Re: Location for common store/admin defines?
move those constants to the catalog side. keep it simple. then use the include the way swguy stated above.