Witam ,
udało mi się zainstalować moduł ship2pay dla wersji 1.4.
opiszę poniżej jak to zrobić:
1. Należy mieć w bazie tablicę ship2pay ,jeżeli ktoś miał w poprzedniej wersji należy ją przenieść, albo założyć od nowa.
2.kopiujemy ze starszej wersji moduł ship2pay do nowej wersji 1.4 w to samo miejsce (katalog moduły)
w panelu administracyjnym w zakładce moduły w sekcji inne moduły pojawi się nasz "ship to pay".
3 następnie modyfikujemy następujące pliki (wcześniej robimy ich kopię)
a) classes->module.php
dopisać dwie funkcje:
//ship2pay//
public static function hookExecFront($carrier,$hook_name,$hookArgs = array(), $id_module = NULL)
{
if ((!empty($id_module) AND !Validate::isUnsignedId($id_module)) OR !Validate::isHookName($hook_name))
die(Tools::displayError());
$output = '';
global $cart, $cookie;
$sql='SELECT * FROM `'._DB_PREFIX_.'shiptopay`';
$result = Db::getInstance()->ExecuteS($sql);
if(count($result)==0){
Module::hookExec($hook_name);
} else
{
if (!isset($hookArgs['cookie']) OR !$hookArgs['cookie'])
$hookArgs['cookie'] = $cookie;
if (!isset($hookArgs['cart']) OR !$hookArgs['cart'])
$hookArgs['cart'] = $cart;
$hook_name = strtolower($hook_name);
if (!isset(self::$_hookModulesCache))
{
$db = Db::getInstance(_PS_USE_SQL_SLAVE_);
$result = $db->ExecuteS('
SELECT distinct(stp.id_carrier), h.`name` as hook, m.`id_module`, h.`id_hook`, m.`name` as module
FROM `'._DB_PREFIX_.'module` m
LEFT JOIN `'._DB_PREFIX_.'hook_module` hm ON hm.`id_module` = m.`id_module`
LEFT JOIN `'._DB_PREFIX_.'hook` h ON hm.`id_hook` = h.`id_hook`
LEFT JOIN `'._DB_PREFIX_.'shiptopay` stp ON hm.`id_module` = stp.`id_payment`
WHERE stp.id_carrier='.intval($carrier).'
AND m.`active` = 1
ORDER BY hm.`position`', false);
self::$_hookModulesCache = array();
while ($row = $db->nextRow())
{
$row['hook'] = strtolower($row['hook']);
if (!isset(self::$_hookModulesCache[$row['hook']]))
self::$_hookModulesCache[$row['hook']] = array();
self::$_hookModulesCache[$row['hook']][] = array('id_hook' => $row['id_hook'], 'module' => $row['module'], 'id_module' => $row['id_module']);
}
}
if (!isset(self::$_hookModulesCache[$hook_name]))
return;
$altern = 0;
foreach (self::$_hookModulesCache[$hook_name] AS $array)
{
if ($id_module AND $id_module != $array['id_module'])
continue;
if (!($moduleInstance = Module::getInstanceByName($array['module'])))
continue;
$exceptions = $moduleInstance->getExceptions((int)$array['id_hook'], (int)$array['id_module']);
foreach ($exceptions AS $exception)
if (strstr(basename($_SERVER['PHP_SELF']).'?'.$_SERVER['QUERY_STRING'], $exception['file_name']))
continue 2;
if (is_callable(array($moduleInstance, 'hook'.$hook_name)))
{
$hookArgs['altern'] = ++$altern;
$output .= call_user_func(array($moduleInstance, 'hook'.$hook_name), $hookArgs);
}
}
}
return $output;
}
oraz :
public static function hookExecPaymentFront($carrier)
{
global $cart, $cookie;
$hookArgs = array('cookie' => $cookie, 'cart' => $cart);
$id_customer = (int)($cookie->id_customer);
$billing = new Address((int)($cart->id_address_invoice));
$output = '';
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
SELECT DISTINCT (stp.id_carrier), h.`id_hook`, m.`name`, hm.`position`
FROM `'._DB_PREFIX_.'module_country` mc
LEFT JOIN `'._DB_PREFIX_.'module` m ON m.`id_module` = mc.`id_module`
INNER JOIN `'._DB_PREFIX_.'module_group` mg ON (m.`id_module` = mg.`id_module`)
INNER JOIN `'._DB_PREFIX_.'customer_group` cg on (cg.`id_group` = mg.`id_group` AND cg.`id_customer` = '.(int)($id_customer).')
LEFT JOIN `'._DB_PREFIX_.'hook_module` hm ON hm.`id_module` = m.`id_module`
LEFT JOIN `'._DB_PREFIX_.'hook` h ON hm.`id_hook` = h.`id_hook`
LEFT JOIN `'._DB_PREFIX_.'shiptopay` stp ON hm.`id_module` = stp.`id_payment`
WHERE h.`name` = \'payment\'
AND stp.id_carrier='.intval($carrier).'
AND mc.id_country = '.(int)($billing->id_country).'
AND m.`active` = 1
ORDER BY hm.`position`, m.`name` DESC');
if ($result)
foreach ($result AS $k => $module)
if (($moduleInstance = Module::getInstanceByName($module['name'])) AND is_callable(array($moduleInstance, 'hookpayment')))
if (!$moduleInstance->currencies OR ($moduleInstance->currencies AND sizeof(Currency::checkPaymentCurrencies($moduleInstance->id))))
$output .= call_user_func(array($moduleInstance, 'hookpayment'), $hookArgs);
return $output;
}
b) w pliku controllers->OrderController.php
w funkcji :
protected function _assignPayment()
w miejsce linijki:
'HOOK_PAYMENT' => Module::hookExecPayment(),
wpisać:
'HOOK_PAYMENT' => Module::hookExecPaymentFront(Tools::getValue('id_carrier')),
c) w pliku controllers->OrderOpcController.php
w funkcji:
public function preProcess()
w sekcji:
case 'getPaymentModule':
w miejsce linijki :
$return = Module::hookExec('payment');
wpisać:
$return = Module::hookExecFront($this->cart->id_carrier,'payment');
To by było na tyle po tych modyfikacjach moduł ship2pay powinien działać.
Pozdrawiam
Art