$cid = (int)$this->customer->getId();
$pid = (int)$product_query->row['product_id'];
$customer_new = $this->db->query("
SELECT tb03.customer_id, tb01.product_id AS prod_id, tb04.jan - sum(tb01.quantity) AS kolichestvo
FROM oc_order_product AS tb01
LEFT JOIN oc_order AS tb02 ON tb01.order_id = tb02.order_id
LEFT JOIN oc_customer AS tb03 ON tb02.customer_id = tb03.customer_id
LEFT JOIN oc_product AS tb04 ON tb01.product_id = tb04.product_id
WHERE tb03.customer_id = '{$cid}'
GROUP BY tb03.customer_id, tb01.product_id
");
$rows = $customer_new->rows;
foreach($rows as $index => $row){
$ssd[] = array(
'prod_idsss' => $row['prod_id'],
'kolichestvo' => $row['kolichestvo']
);
}
if($cid>'0') {
$pppo = $this->db->query("SELECT op.quantity FROM oc_order_product AS op LEFT JOIN oc_order AS o ON o.order_id=op.order_id WHERE o.customer_id='".$cid."' AND product_id = '" . (int)$product_query->row['product_id'] . "' ");
if(isset($pppo->row['quantity']) AND !empty($pppo->row['quantity']) AND $pppo->row['quantity']>'0') {
$nqty = $pppo->row['quantity'];
} else {
$nqty = '0';
}
$ppp = $this->db->query("SELECT isbn, jan FROM " . DB_PREFIX . "product WHERE product_id = '" . (int)$product_query->row['product_id'] . "' LIMIT 1");
$iss = $ppp->row['isbn'];
$jan = $ppp->row['jan'];
$jjan = (int)$jan-(int)$nqty;
// $jjan = $jan-$nqty;
// print_r($jjan);
if($jjan<'0') {
if($jjan>'0') {
if($cart['quantity']<$jjan) {
$ppp = $this->db->query("SELECT isbn, jan FROM " . DB_PREFIX . "product WHERE product_id = '" . (int)$product_query->row['product_id'] . "' LIMIT 1");
$iss = $ppp->row['isbn'];
if($iss>'0') {
$price = $price-$price/100*$iss;
} else {
}
}
}
} else {
$ppp = $this->db->query("SELECT isbn, jan FROM " . DB_PREFIX . "product WHERE product_id = '" . (int)$product_query->row['product_id'] . "' LIMIT 1");
$iss = $ppp->row['isbn'];
$jan = $ppp->row['jan'];
if($jan>'0') {
if($cart['quantity']<$jan) {
// $pp = $this->model_catalog_product->getProduct($product_query->row['product_id']);
$ppp = $this->db->query("SELECT isbn, jan FROM " . DB_PREFIX . "product WHERE product_id = '" . (int)$product_query->row['product_id'] . "' LIMIT 1");
$iss = $ppp->row['isbn'];
// print_r('-');
// print_r($iss);
if($iss>'0') {
$price = $price-$price/100*$iss;
// $product['price'] = $product['price']/100*40;
} else {
// $product['price'] = $product['price']/100*40;
}
}
}
}
} else {
}
$product_data[] = array(
'cart_id' => $cart['cart_id'],
'product_id' => $product_query->row['product_id'],
'name' => $product_query->row['name'],
'model' => $product_query->row['model'],
'shipping' => $product_query->row['shipping'],
'isbn' => $product_query->row['isbn'],
'image' => $product_query->row['image'],
'option' => $option_data,
'download' => $download_data,
'quantity' => $cart['quantity'],
'minimum' => $product_query->row['minimum'],
'subtract' => $product_query->row['subtract'],
'stock' => $stock,
'price' => ($price + $option_price),
'total' => ($price + $option_price) * $cart['quantity'],
'reward' => $reward * $cart['quantity'],
'points' => ($product_query->row['points'] ? ($product_query->row['points'] + $option_points) * $cart['quantity'] : 0),
'tax_class_id' => $product_query->row['tax_class_id'],
'weight' => ($product_query->row['weight'] + $option_weight) * $cart['quantity'],
'weight_class_id' => $product_query->row['weight_class_id'],
'length' => $product_query->row['length'],
'width' => $product_query->row['width'],
'height' => $product_query->row['height'],
'length_class_id' => $product_query->row['length_class_id'],
'recurring' => $recurring
);
} else {
$this->remove($cart['cart_id']);
}
}
// print_r($product_data);
return $product_data;
}
Добрый день как можно customer(пользователя) product_id(купленный товар айди) сравнить с product_id(всего интернет магазина) и по полю в cumtomer kolichestvo делать if $kolichestvo > 0 ?
Виртуальный выделенный сервер (VDS) становится отличным выбором
Мне надо удалить объект из jsonНапример, у меня есть вот такая json-запись: { "+79123456789": { "name":"name", "date":"date", "time":"time" } Как реализовать на php удаление...
Не подскажите, как сделать 30 секундный обратный таймер на странице, который не меняется при обновлении страницы или при изменении пользователем...
Есть таблица HTML которую я заношу в массив на JSДалее необходимо перенести массив из JS в массив PHP для дальнейшей работы
Подскажите пожалуйста, есть код который выводит данные из таблицы с помощью цикла: