Ответить Новая тема Новый опрос 
 оплата при получении повышает стоимость
werru
Новичок
Сообщений: 7
Регистрация: 10-03-2015


19-11-2015 17:44
Как сделать, что если выбирается оплата наличными при получении учитывается способ отправки и формируется окончательная цена.
т.е. при выборе
самовывоза 0% к оплате
курьера +2,5% к общей цене
для почты такого варианта нет. ну её
 
Вне форума
ПМ 
Щелкните, и это сообщение будет добавлено в ваш ответ как цитата Цитировать этот ответ
werru
Новичок
Сообщений: 7
Регистрация: 10-03-2015


22-11-2015 14:06
очень прошу помочь
мне нужен был модуль, что добавляет к стоимости товара % если выбирается определённые способы оплаты. Я нашёл такой, он добавлял фиксированную сумму - переделал на процент. НО проблема в том, что у меня несколько вариантов оплаты и процентов (в том числе без процентов). Я клонировал модуль в 2х варинтах. И вылез косяк...
Если менять способы доставки, то в какой-то момент один модуль перестаёт появляться. Думаю, что виноват какой-то момент отлова переключения, т.е. первый модуль поймал событие, а второй его не увидел. ЧТО хотя бы смотреть надо?

переделанный модуль https://yadi.sk/d/vlyjF1aikdzHr




грешу на эту часть
public function install()
{
if (!parent::install()
OR !$this->registerHook('payment')
OR !$this->registerHook('paymentReturn')
OR !$this->registerHook('actionCarrierUpdate')
)
return false;
if((int)Configuration::get('PS_OS_PREPARATION'))
return true;

Db::getInstance()->autoExecuteWithNullValues('ps_order_state',$values,'INSERT');

$lastid=Db::getInstance()->Insert_ID();
if($lastid) {
Configuration::updateValue('COD3_STATE', $lastid, 0, 0 );
$translations=array('cs'=>'V přípravě - dobírka');
$langs=Language::getLanguages();
foreach($langs as $lang) {
$name=isset($translations[$lang['iso_code']])?$translations[$lang['iso_code']]:'In preparation - COD';
$values=array(
'id_order_state'=>$lastid,
'id_lang'=>$lang['id_lang'],
'name'=>pSQL($name),
'template'=>pSQL($this->name),
);
Db::getInstance()->AutoExecute('ps_order_state_lang',$values,'INSERT');

}


}

}


public function getContent()
{
require_once(_PS_MODULE_DIR_.$this->name.'/PrestahostUpgrade.php');


$this->_html = '<h2>'.$this->displayName.'</h2>';
$this->_html .=PrestahostUpgrade::displayInfo($this->name, $this->version, Context::getContext()->language);

if (!empty($_POST))
{
$this->_postValidation();
if (!sizeof($this->_errors))
$this->_postProcess();
else
foreach ($this->_errors AS $err)
$this->_html .= '<div class="alert error">'. $err .'</div>';
}
else
$this->_html .= '<br />';

$this->_displayCod();
$this->_displayForm();

return $this->_html;
}




public function hookPayment($params)
{

if (!$this->active)
return ;

if(!$this->isAllowedCarrier($this->getCarrierId($params)))
return false;

global $smarty;

// Check if cart has product download
foreach ($params['cart']->getProducts() AS $product)
{
$pd = ProductDownload::getIdFromIdProduct((int)($product['id_product']));
if ($pd AND Validate::isUnsignedInt($pd))
return false;
}

$smarty->assign(array(
'this_path' => $this->_path,
'this_path_ssl' => Tools::getShopDomainSsl(true, true).__PS_BASE_URI__.'modules/'.$this->name.'/'
));

$amountPaid=$this->context->cart->getOrderTotal(true, Cart::BOTH_WITHOUT_SHIPPING);
if($this->feefree > 0 && $amountPaid > Tools::convertPrice($this->feefree)) {
$smarty->assign(array(
'codfee' => $this->l('Free!')));
} else {
$this->fee=$amountPaid/100*$this->fee; ///////////////////////////////////
$amountPaid=$amountPaid+$this->fee;
$smarty->assign(array(
// 'codfee' => Tools::displayPrice (Tools::convertPrice($this->context->cart->getOrderTotal(true, Cart::BOTH_WITHOUT_SHIPPING)*fee/100))));
'codfee' => Tools::displayPrice (Tools::convertPrice($this->fee))));
}


// print_R(get_defined_vars());
return $this->display(__FILE__, 'payment3.tpl');
}

protected function getCarrierId($params) {
if((int) $params['cart']->id_carrier)
return (int) $params['cart']->id_carrier;

$option=$this->context->cart->getDeliveryOption(null, false);
if(is_array($option)) {
$vals=array_values($option);
return (int)$vals[0];
}
}


public function hookPaymentReturn($params)
{
if (!$this->active)
return ;

return $this->display(__FILE__, 'confirmation3.tpl');
}

public function hookActionCarrierUpdate($params) {
$this->_renumberCarriers($params);
Configuration::updateValue('COD3_CARRIERS', serialize($this->allowed_carriers ));

}




Вложения:

Вложения cashondeliverypluspersentage3.zip( Размер файла: 42.95KB Скачиваний: 125 )
 
Вне форума
ПМ 
Щелкните, и это сообщение будет добавлено в ваш ответ как цитата Цитировать этот ответ
ruleoffdv


Cпециалист
Сообщений: 209
Регистрация: 05-05-2013


04-12-2016 23:03
Купите модуль и не мучайтесь у меня ест. МОУ поменять
 
Вне форума
ПМ 
Щелкните, и это сообщение будет добавлено в ваш ответ как цитата Цитировать этот ответ
Ответить Новая тема Новый опрос