In helper.php line 760 would it be possible to check for the existance of a class file in either the site or admin template locations?
The purpose would be to reduce the risk of any class customisations a developer may have made getting accidently overridden during a Hikashop upgrade.
I.E. change code
if(!class_exists($className)) include_once(constant(strtoupper('HIKASHOP_'.$group)).$class.'.php');
to something like this:
if(!class_exists($className)) {
$app = JFactory::getApplication();
$classfile= JPATH_SITE . DS . 'templates'.DS.$app->getTemplate().DS.'classes'.DS.'com_hikashop'.DS.$class.'.php'
if (file_exists($classfile)) {
// Add some way of checking if custom class is compatible with installed Hikashop version
// If not then produce an error
include_once($classfile);
}
else {
$classfile= JPATH_ADMINISTRATOR . DS . 'templates'.DS.$app->getTemplate().DS.'classes'.DS.'com_hikashop'.DS.$class.'.php'
if (file_exists($classfile)) {
// Add some way of checking if custom class is compatible with installed Hikashop version
// If not then produce an error
include_once($classfile);
}
}
if(!class_exists($className)) include_once(constant(strtoupper('HIKASHOP_'.$group)).$class.'.php');
This idea came about while thinking of possible solutions to the following topics:
11199-coupons-and-discounts
27448-coupons-for-specific-products
Another idea was for a couple of new functions which could be called by a plug-in:
onBeforeVoucherAdded
onAfterVoucherAdded
These would be invoked in
loadAndCheck function of
discount.php something like this:
function loadAndCheck($coupon_code,&$total,$zones,&$products,$display_error=true){
$coupon = $this->load($coupon_code);
if (...onBeforeVoucherAdded... exists) {
$beforeResult = ...->onBeforeVoucherAdded($coupon,$total,$zones,$products,$display_error);
if ($beforeResult === FALSE) return null;
if (is_object($beforeResult)) return $beforeResult;
}
$result = $this->check($coupon,$total,$zones,$products,$display_error);
if (...onAfterVoucherAdded... exists) {
$afterResult = ...->onAfterVoucherAdded($result,$coupon,$total,$zones,$products,$display_error);
if ($afterResult === FALSE) return null;
if (is_object($afterResult)) return $afterResult;
}
return $result;
}
Any other ideas if how this moght be achieved?