Answer the question
In order to leave comments, you need to log in
How to fix the Shopkeeper "cart"?
Hello
There is one ancient site on Evo 1.0.10 + Shopkeeper 1.3.4, the problem occurs when changing the number of items in the cart. Do not tell me where to dig?
Essence:
If you try to change the number of goods in the cart, then the product display snippet simply displays its call code in text form
Moreover, the cart works, when you reload the page using F5, all changes are considered and the snippet is displayed normally.
SK_custom code under the spoiler
<?php
if($_POST['formid']=='shopOrderForm'){
$array_product = array();
return '<div class="hide hide_cart">1</div>';
}
else{
$array_product = unserialize($_SESSION["purchases"]) ? unserialize($_SESSION["purchases"]) : array();
}
if($type == 'product'){ //if product
$count_product = 0;
$out = '
<table width="100%" cellpadding="0" cellspacing="0" class="catalog-table">
<tr>
<td align="left">Название товара</td>
<td align="center">Количество товара</td>
<td align="center">Стоимость</td>
<td align="center">Общая стоимость</td>
<td align="center">Удалить</td></tr>
</tr>';
$price_total = 0;
foreach($array_product as $key => $product_data){
if(!$product_data[0]) continue;
/**
* $product_data[0] - $id
* $product_data['catalog']
* $product_data[1] - count prooduct
* $product_data[2] - price prooduct
**/
$Document = $modx->getDocument($product_data[0],'*');
$units = 'кв.м.';
$res_u = $modx->db->query( '
SELECT value
FROM `site_tmplvar_contentvalues`
WHERE `contentid` = '.$Document['parent'].'
and tmplvarid = 112
' );
if($res_u){
$row_u = $modx->db->getRow( $res_u );
$units = $row_u['value'];
}
//class for hide services
$class = '';
//if not product
if($Document['template'] != 6){
$class = "hide";
}
else{
$price_total += $product_data[2] * $product_data[1];
$count_product++;
}
$out .= '<tr class="' . $class . ' product">';
$out .= '
<td align="left">
<a href="' . $modx->makeUrl($Document['id']) . '">' . $Document['pagetitle'] . '</a>
</td>
<td align="center">
<div class="numb"><a class="minus hide" href="#" onClick="alert(\"Это консоль!\")">-</a><input type="text" name="count[]" class="num shk-count" value="' . $product_data[1] . '"><a class="hide plus" href="#">+</a></div>
</td>
<td align="center">' . $product_data[2] . ' руб. за ' . $units . '</td>
<td align="center">' . $product_data[2] * $product_data[1] . ' руб.</td>
<td><a href="' . $modx->makeUrl(80, '', '?shk_action=del&n='.$key,'http') . '" id="dell_' . $key . '" class="dell shk-del" align="center"></a></td>
';
$out .= '</tr>';
}
//var_dump(count_product );die();
$out .= '
</table>
<div class="total"><p>Общая стоимость: <span onChange="updateForm()">' . $price_total . ' рублей</span></p></div>
';
if(!$count_product){
$out .= '<div class="hide_parent hide">1</div>';
}
print $out;
}
elseif($type == 'service'){ //if sercive
if(!$array_product){
return '<!--<div id="cartEmpty" style="text-align:center;">Пусто</div>-->';
}
$count_service = 0;
$out = '
<table width="100%" cellpadding="0" cellspacing="0" class="catalog-table">
<tr>
<td align="left">Название товара</td>
<td align="center">Стоимость</td>
<td align="center">Пояснение</td>
<td align="center">Удалить</td></tr>
<tr>';
$price_total = 0;
foreach($array_product as $key => $product_data){
/**
* $product_data[0] - $id
* $product_data['catalog']
* $product_data[1] - count prooduct
* $product_data[2] - price prooduct
**/
$Document = $modx->getDocument($product_data[0],'*');
//class for hide services
$class = '';
//if not product
if($Document['template'] == 6){
$class = "hide";
}
else{
$price_total += $product_data[2] * $product_data[1];
$count_service++;
}
$out .= '<tr class="' . $class . '">';
$out .= '
<td align="left">
<a href="' . $modx->makeUrl($Document['id']) . '">' . $Document['pagetitle'] . '</a>
</td>
<td align="center" class="td_price">' . ($product_data[2] ? $product_data[2] : 'договорная') . '</td>
<td align="left">' . $Document['introtext'] . '</td>
<td><a href="' . $modx->makeUrl(80, '', '?shk_action=del&n='.$key,'http') . '" class="dell_fake dell shk-del" id="' . $key . '" align="center"></a></td>
';
$out .= '</tr>';
}
if($count_service){
$out .= '
</table>
<div class="total"><p><span>' . $price_total . ' рублей</span></p></div>
';
$out = '
<h2>Заказанные услуги</h2>
<div class="bord-grad">
' . $out . '
</div>
';
}
else{
$out = '';
}
print $out;
}
elseif($type=='total'){
$price_total = 0;
foreach($array_product as $key => $product_data){
/**
* $product_data[0] - $id
* $product_data['catalog']
* $product_data[1] - count prooduct
* $product_data[2] - price prooduct
**/
$price_total += $product_data[2] * $product_data[1];
}
print $price_total;
}
elseif($type=='bought'){
$square_total = 0;
foreach($array_product as $key => $product_data){
/**
* $product_data[0] - $id
* $product_data['catalog']
* $product_data[1] - count prooduct
* $product_data[2] - price prooduct
**/
$Document = $modx->getDocument($product_data[0],'*');
$result_allowed_filters = $modx->db->query( 'SELECT * FROM `site_tmplvar_contentvalues` WHERE tmplvarid != 65 AND contentid = ' . $Document['parent'] );
$allowed_string = $modx->db->getRow( $result_allowed_filters );
if($Document['template'] == 6 && strpos($allowed_string['value'],"кв.м.")!==FALSE){
$square_total += $product_data[1] ;
}
}
print $square_total;
}
elseif($type=='discount'){
$result = $modx->getTemplateVar('discount', '*', 80, 1);
$discount = (int)$result['value'];
$square_total = 0;
foreach($array_product as $key => $product_data){
/**
* $product_data[0] - $id
* $product_data['catalog']
* $product_data[1] - count prooduct
* $product_data[2] - price prooduct
**/
$Document = $modx->getDocument($product_data[0],'*');
$result_allowed_filters = $modx->db->query( 'SELECT * FROM `site_tmplvar_contentvalues` WHERE tmplvarid != 65 AND contentid = ' . $Document['parent'] );
$allowed_string = $modx->db->getRow( $result_allowed_filters );
//var_dump($allowed_string);
if($Document['template'] == 6 && strpos($allowed_string['value'],"кв.м.")!==FALSE){
$square_total += $product_data[1] ;
}
}
print $square_total*($discount/100);
}
?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question