Jump to content
Sign in to follow this  

Recommended Posts

Hello community, since the topic for stats_unsold_cart has been closed, i open a new one. This is the following contribution:

https://forums.oscommerce.com/topic/61365-abandoned-carts/?page=9

I changed the content of the file a bit to place attributes on the products. Now the prices are still missing. If someone wants to help, it would make it easier for everyone who wants to see the customer shopping cart in the admin area to keep track of their work.

Testet on Bootstrap 2.3.4-1 EDGE

Here is the file:

 

<?php

  require('includes/application_top.php');
  require('includes/template_top.php');

	$cid = (isset($_GET['cid']) ? $_GET['cid'] : '');
	$cartlist = array();
	$customers_query = tep_db_query("select distinct customers_id from customers_basket");
	while ($c = tep_db_fetch_array($customers_query)) $cartlist[] = $c['customers_id'];

?>
<style>
.margin-box-inner{padding:2px;padding-left:15px;}
.box-border-dark{border:1px solid transparent;border-radius:2px;border-color:#666666;}
.bg-box-blue{background-color: #C6F3FF !important;border:1px solid transparent;border-radius:2px;border-color:#0584A9;}
.bg-box-green{background-color: #DFF0D8 !important;border:1px solid transparent;border-radius:2px;border-color:#61AA42;}
.bg-box-yellow{background-color: #FCF8E3 !important;border:1px solid transparent;border-radius:2px;border-color:#EED960;}
.bg-box-red{background-color: #F2DEDE !important;border:1px solid transparent;border-radius:2px;border-color:#990000;}
.text-box-head-inner{color: #000000;font-size: 16px;font-weight:bold;}
.text-box-aton-inner{color: #FF0000;font-size: 14px;font-weight:bold;}
.text-box-atovan-inner{color: #000000;font-size: 12px;font-weight:bold;font-style: italic;}
.text-box-count-inner{color: #990000;font-weight:bold;font-style: italic;}
.text-box-center{text-align: center;}
.font-effect-shadow-multiple{}
.wrapper{position:relative;}
.window:hover > .window-text, .window:hover > .wrapper {pointer-events: auto;opacity: 1.0;}
.window > .window-text, .window >.wrapper {display: block;position: absolute;z-index: 6000;overflow: visible;line-height: 16px;padding: 8px;margin: 8px;text-align: left;color: #000;background: #fff;border:1px solid #990000;left:-70px; top:40px; border-radius: 4px;pointer-events: none;opacity: 0.0;-o-transition: all 0.3s ease-out;-ms-transition: all 0.3s ease-out;-moz-transition: all 0.3s ease-out;-webkit-transition: all 0.3s ease-out;transition: all 0.3s ease-out;}
.wrapper > .window-text {overflow-y: auto;max-height: 400px;width: 700px;display: block;}
</style>      
<div class="col-sm-12 pageHeading pls_pdl_margin"><?php echo HEADING_TITLE; ?></div>
<?php if (empty($cartlist)) { ?>
<div class="col-sm-12 bg-box-red margin-box-inner"><?php echo TABLE_HEADING_CART_EMPTY; ?></div>
<?php }else{?>

<?php
  $customers_query_raw = "select customers_id, customers_firstname, customers_lastname from customers where customers_id in(" . implode(",", $cartlist) . ") order by customers_lastname, customers_firstname desc";
  $customers_query = tep_db_query($customers_query_raw);
  while ($customers = tep_db_fetch_array($customers_query)) {
  $customer_name = $customers['customers_firstname'] . '&nbsp;' . $customers['customers_lastname'];

  $products_query = tep_db_query("select count(products_id) as total from customers_basket where customers_id = " . (int)$customers['customers_id']);
  $products = tep_db_fetch_array($products_query);
  $selected['count'] = $products['total'];
  $csct = $products['total'];

  $cart_data_query = tep_db_query("select * from customers_basket where customers_id = " . (int)$customers['customers_id']);
  $cdq = tep_db_fetch_array($cart_data_query);
  $dr = substr($cdq['customers_basket_date_added'], 0, 4) . '-' . substr($cdq['customers_basket_date_added'], 4, 2) . '-' . substr($cdq['customers_basket_date_added'], 6, 2);

?>
<div class="col-sm-12 margin-box-inner">
<div class="row bg-box-blue">
<div class="col-sm-3 pls_pdl_margin"><?php echo $customer_name; ?></div>
<div class="col-sm-3 pls_pdl_margin"><?php echo TABLE_HEADING_CART_PROD_TOTAL . '&nbsp;' . $csct;?></div>
<div class="col-sm-3 pls_pdl_margin"><?php echo TABLE_HEADING_ADD_TO_CART_DATE . '&nbsp;' . tep_date_short($dr);?></div>
</div>
<?php
  $prod_query = tep_db_query("select * from customers_basket where customers_id = " . (int)$customers['customers_id']);
  while ($prod = tep_db_fetch_array($prod_query)) {
  $date_raw = substr($prod['customers_basket_date_added'], 0, 4) . '-' . substr($prod['customers_basket_date_added'], 4, 2) . '-' . substr($prod['customers_basket_date_added'], 6, 2);
  $name_query = tep_db_query("select products_name from products_description where products_id = " . (int)$prod['products_id']);
  $pname = tep_db_fetch_array($name_query);
?>

<div class="row bg-box-yellow margin-box-inner">

<span class="text-box-head-inner"><?php echo $prod['customers_basket_quantity'] . ' x ' . $pname['products_name'];?></span><br>

<?php
  $att_query = tep_db_query("select products_options_id, products_options_value_id from customers_basket_attributes where customers_id = " . (int)$customers['customers_id'] . " and products_id ='" . tep_db_input($prod['products_id']) . "'");
  if (tep_db_num_rows($att_query)) {
  while ($att = tep_db_fetch_array($att_query)) {
  $attributes = tep_db_query("select popt.products_options_name, poval.products_options_values_name from products_options popt, products_options_values poval, products_attributes pa where pa.products_id = '" . (int)$prod['products_id'] . "' and pa.options_id = '" . (int)$att['products_options_id'] . "' and pa.options_id = popt.products_options_id and pa.options_values_id = '" . (int)$att['products_options_value_id'] . "' and pa.options_values_id = poval.products_options_values_id and popt.language_id = '" . (int)$languages_id . "' and poval.language_id = '" . (int)$languages_id . "'");
  $attrib = tep_db_fetch_array($attributes);
?>

<?php if ($attrib['products_options_values_name'] > ' '){echo '<span class="text-box-aton-inner">' . $attrib['products_options_name'] . ': </span><span class="text-box-atovan-inner">' . $attrib['products_options_values_name'] . '</span><br>';}?>

<?php
  } // while ($att = tep_db_fetch_array($att_query)) {
 } // if (tep_db_num_rows($att_query)) {
?>
</div>

<?php } /* while ($prod = tep_db_fetch_array($prod_query)) { */ ?>

<?php echo tep_black_line(); ?>
</div>
<?php } /* while ($customers = tep_db_fetch_array($customers_query)) { */ ?>

<?php } /* }else{ */ ?>
<?php
  require('includes/template_bottom.php');
  require('includes/application_bottom.php');
?>

 

here the language file: (only german)

<?php
/*
  $Id:$

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2020 osCommerce

  Released under the GNU General Public License
*/

define('HEADING_TITLE', 'Kundenwarenkorb * V 1.1');

define('TABLE_HEADING_ADD_TO_CART_DATE', 'Datum: ');
define('TABLE_HEADING_CUSTOMER_NAME', 'Name: ');
define('TABLE_HEADING_CART_PROD_TOTAL', 'Produkte im Warenkorb: ');
define('TABLE_HEADING_CART_EMPTY', 'Es sind keine Produkte im Kundenwarenkorb hinterlegt.');
?>

 

I hope someone takes some time to expand it so that everyone can benefit from it

Share this post


Link to post
Share on other sites

file with product price

<?php

  require('includes/application_top.php');
  require('includes/classes/' . 'currencies.php');
  $currencies = new currencies();
  require('includes/template_top.php');

	$cid = (isset($_GET['cid']) ? $_GET['cid'] : '');
	$cartlist = array();
	$customers_query = tep_db_query("select distinct customers_id from customers_basket");
	while ($c = tep_db_fetch_array($customers_query)) $cartlist[] = $c['customers_id'];

?>
<style>
.pdl_box_margin{margin:10px;}
.margin-box-inner{padding:2px;padding-left:15px;}
.box-border-dark{border:1px solid transparent;border-radius:2px;border-color:#666666;}
.bg-box-blue{background-color: #C6F3FF !important;border:1px solid transparent;border-radius:2px;border-color:#0584A9;}
.bg-box-green{background-color: #DFF0D8 !important;border:1px solid transparent;border-radius:2px;border-color:#61AA42;}
.bg-box-yellow{background-color: #FCF8E3 !important;border:1px solid transparent;border-radius:2px;border-color:#EED960;}
.bg-box-red{background-color: #F2DEDE !important;border:1px solid transparent;border-radius:2px;border-color:#990000;}
.text-box-head-inner{color: #000000;font-size: 16px;font-weight:bold;}
.text-box-aton-inner{color: #FF0000;font-size: 14px;font-weight:bold;}
.text-box-atovan-inner{color: #000000;font-size: 12px;font-weight:bold;font-style: italic;}
.text-box-count-inner{color: #990000;font-weight:bold;font-style: italic;}
.text-box-center{text-align: center;}
.font-effect-shadow-multiple{}
.wrapper{position:relative;}
.window:hover > .window-text, .window:hover > .wrapper {pointer-events: auto;opacity: 1.0;}
.window > .window-text, .window >.wrapper {display: block;position: absolute;z-index: 6000;overflow: visible;line-height: 16px;padding: 8px;margin: 8px;text-align: left;color: #000;background: #fff;border:1px solid #990000;left:-70px; top:40px; border-radius: 4px;pointer-events: none;opacity: 0.0;-o-transition: all 0.3s ease-out;-ms-transition: all 0.3s ease-out;-moz-transition: all 0.3s ease-out;-webkit-transition: all 0.3s ease-out;transition: all 0.3s ease-out;}
.wrapper > .window-text {overflow-y: auto;max-height: 400px;width: 700px;display: block;}
</style>      
<div class="col-sm-12 pageHeading pls_pdl_margin"><?php echo HEADING_TITLE; ?></div>
<?php if (empty($cartlist)) { ?>
<div class="col-sm-12 bg-box-red pdl_box_margin"><?php echo TABLE_HEADING_CART_EMPTY; ?></div>
<?php }else{?>

<?php
  $customers_query_raw = "select customers_id, customers_firstname, customers_lastname from customers where customers_id in(" . implode(",", $cartlist) . ") order by customers_lastname, customers_firstname desc";
  $customers_query = tep_db_query($customers_query_raw);
  while ($customers = tep_db_fetch_array($customers_query)) {
  $customer_name = $customers['customers_firstname'] . '&nbsp;' . $customers['customers_lastname'];

  $products_query = tep_db_query("select count(products_id) as total from customers_basket where customers_id = " . (int)$customers['customers_id']);
  $products = tep_db_fetch_array($products_query);
  $selected['count'] = $products['total'];
  $csct = $products['total'];

  $cart_data_query = tep_db_query("select * from customers_basket where customers_id = " . (int)$customers['customers_id']);
  $cdq = tep_db_fetch_array($cart_data_query);
  $dr = substr($cdq['customers_basket_date_added'], 0, 4) . '-' . substr($cdq['customers_basket_date_added'], 4, 2) . '-' . substr($cdq['customers_basket_date_added'], 6, 2);

?>
<div class="col-sm-12 margin-box-inner">
<div class="row bg-box-blue">
<div class="col-sm-3 pls_pdl_margin"><?php echo $customer_name; ?></div>
<div class="col-sm-3 pls_pdl_margin"><?php echo TABLE_HEADING_CART_PROD_TOTAL . '&nbsp;' . $csct;?></div>
<div class="col-sm-3 pls_pdl_margin"><?php echo TABLE_HEADING_ADD_TO_CART_DATE . '&nbsp;' . tep_date_short($dr);?></div>
</div>
<?php
  $prod_query = tep_db_query("select * from customers_basket where customers_id = " . (int)$customers['customers_id']);
  while ($prod = tep_db_fetch_array($prod_query)) {
  $date_raw = substr($prod['customers_basket_date_added'], 0, 4) . '-' . substr($prod['customers_basket_date_added'], 4, 2) . '-' . substr($prod['customers_basket_date_added'], 6, 2);
  $prod_id = tep_get_prid($prod[products_id]);

  $name_query = tep_db_query("select pd.products_id, 
                                     pd.products_name name, 
                                     pd.products_description, 
                                     p.products_id,
                                     p.products_price,
                                     p.products_model model,
                                     p.products_image image,
                                     p.products_tax_class_id tcid,
                                     s.status,
                                     IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, 
                                     IF(s.status, s.specials_new_products_price, p.products_price) as final_price 
                                FROM " . TABLE_PRODUCTS . " p, 
                                     " . TABLE_PRODUCTS_DESCRIPTION . " pd 
                                     left join " . TABLE_SPECIALS . " s 
                                     on pd.products_id = s.products_id 
                               WHERE pd.products_id = '" . $prod_id . "' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "'");

  $pname = tep_db_fetch_array($name_query);
  $price = $currencies->format($pname['final_price']);

?>

<div class="row bg-box-yellow margin-box-inner">

<span class="text-box-head-inner"><?php echo $prod['customers_basket_quantity'] . ' x ' . $pname['name'] . $currencies->display_price($price, tep_get_tax_rate($pname['tcid']));?></span><br>

<?php
  $att_query = tep_db_query("select products_options_id, products_options_value_id from customers_basket_attributes where customers_id = " . (int)$customers['customers_id'] . " and products_id ='" . tep_db_input($prod['products_id']) . "'");
  if (tep_db_num_rows($att_query)) {
  while ($att = tep_db_fetch_array($att_query)) {

  $attributes = tep_db_query("select 
                                     popt.products_options_name, 
                                     poval.products_options_values_name 
                                from products_options popt, 
                                     products_options_values poval, 
                                     products_attributes pa 
                               where pa.products_id = '" . (int)$prod['products_id'] . "' and 
                                     pa.options_id = '" . (int)$att['products_options_id'] . "' and 
                                     pa.options_id = popt.products_options_id and 
                                     pa.options_values_id = '" . (int)$att['products_options_value_id'] . "' and 
                                     pa.options_values_id = poval.products_options_values_id and 
                                     popt.language_id = '" . (int)$languages_id . "' and 
                                     poval.language_id = '" . (int)$languages_id . "'");
                                     
  $attrib = tep_db_fetch_array($attributes);
?>

<?php if ($attrib['products_options_values_name'] > ' '){echo '<span class="text-box-aton-inner">' . $attrib['products_options_name'] . ': </span><span class="text-box-atovan-inner">' . $attrib['products_options_values_name'] . '</span><br>';}?>

<?php
  } // while ($att = tep_db_fetch_array($att_query)) {
 } // if (tep_db_num_rows($att_query)) {
?>
</div>

<?php } /* while ($prod = tep_db_fetch_array($prod_query)) { */ ?>

<?php echo tep_black_line(); ?>
</div>
<?php } /* while ($customers = tep_db_fetch_array($customers_query)) { */ ?>

<?php } /* }else{ */ ?>
<?php
  require('includes/template_bottom.php');
  require('includes/application_bottom.php');
?>

 

Share this post


Link to post
Share on other sites

new language file #stats_unsold_carts.php

<?php
/*
  $Id:$

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2020 osCommerce

  Released under the GNU General Public License
*/

define('TABLE_HEADING_CART_TITLE', 'Kundenwarenkorb V-1.2 ');

define('TABLE_HEADING_ADD_TO_CART_DATE', 'Datum: ');
define('TABLE_HEADING_CUSTOMER_NAME', 'Name: ');
define('TABLE_HEADING_CART_PROD_TOTAL', 'Menge: ');
define('TABLE_HEADING_CART_EMPTY', 'Es sind keine Produkte im Kundenwarenkorb hinterlegt.');
define('TABLE_HEADING_PRODUCTS_SINGLE_PRICE', 'Einzelpreis: ');
define('TABLE_HEADING_PRODUCTS_QUANTITY_PRICE', 'Produkt-Einzelpreis: ');
define('TABLE_HEADING_PRODUCTS_ATTRIBUTE_PRICE', 'Extras-Totalpreis: ');
define('TABLE_HEADING_PRODUCTS_TOTAL_PRICE', 'Produkt-Gesamtpreis: ');
define('TABLE_HEADING_SEPARATOR', '----------------------------------------------------');
?>

file with price, attribute price, total attribute price and total product price #stats_unsold_carts.php

<?php

  require('includes/application_top.php');
  require('includes/classes/' . 'currencies.php');
  $currencies = new currencies();

	$cid = (isset($_GET['cid']) ? $_GET['cid'] : '');
	$cartlist = array();
	$customers_query = tep_db_query("select distinct customers_id from customers_basket");
	while ($c = tep_db_fetch_array($customers_query)) $cartlist[] = $c['customers_id'];

  if ($_GET['delete_cart']) {
    $messageStack->add(MESSAGE_STACK_CUSTOMER_ID . $_GET['customer_id'] . MESSAGE_STACK_DELETE_SUCCESS, 'success');
  }
  require('includes/template_top.php');
?>
<style>
.pdl_box_margin{margin:10px;}
.margin-box-inner{padding:2px;padding-left:15px;}
.padding_inner{padding-top:6px;padding-bottom:6px;}
.box-border-dark{border:1px solid transparent;border-radius:2px;border-color:#666666;}
.bg-box-blue{background-color: #C6F3FF !important;border:1px solid transparent;border-radius:2px;border-color:#0584A9;}
.bg-box-green{background-color: #DFF0D8 !important;border:1px solid transparent;border-radius:2px;border-color:#61AA42;}
.bg-box-yellow{background-color: #FCF8E3 !important;border:1px solid transparent;border-radius:2px;border-color:#EED960;}
.bg-box-red{background-color: #F2DEDE !important;border:1px solid transparent;border-radius:2px;border-color:#990000;}
.text-box-head-inner{color: #000000;font-size: 16px;font-weight:bold;}
.text-box-aton-inner{color: #FF0000;font-size: 12px;font-weight:bold;}
.text-box-atovan-inner{color: #000000;font-size: 12px;font-weight:bold;font-style: italic;}
.text-box-smal-atovan-inner{color: #000000;font-size: 10px;font-style: italic;}
.text-box-count-inner{color: #990000;font-weight:bold;font-style: italic;}
.text-box-center{text-align: center;}
.text-quant-price{color: #008CEA;font-size: 12px;font-weight:bold;}
.text-attrib-price{color: #03A056;font-size: 12px;font-weight:bold;font-style: italic;}
.text-price-attrib{color: #008CEA;font-size: 12px;font-weight:bold;font-style: italic;}
.text-total-price{color: #000000;font-size: 16px;font-weight:bold;font-style: italic;}
.text-price-total{color: #008CEA;font-size: 16px;font-weight:bold;font-style: italic;}
.font-effect-shadow-multiple{}
.wrapper{position:relative;}
.window:hover > .window-text, .window:hover > .wrapper {pointer-events: auto;opacity: 1.0;}
.window > .window-text, .window >.wrapper {display: block;position: absolute;z-index: 6000;overflow: visible;line-height: 16px;padding: 8px;margin: 8px;text-align: left;color: #000;background: #fff;border:1px solid #990000;left:-70px; top:40px; border-radius: 4px;pointer-events: none;opacity: 0.0;-o-transition: all 0.3s ease-out;-ms-transition: all 0.3s ease-out;-moz-transition: all 0.3s ease-out;-webkit-transition: all 0.3s ease-out;transition: all 0.3s ease-out;}
.wrapper > .window-text {overflow-y: auto;max-height: 400px;width: 700px;display: block;}
</style>      
<div class="col-sm-12 pdl_box_margin pageHeading"><?php echo TABLE_HEADING_CART_TITLE; ?></div>
<?php if (empty($cartlist)) { ?>
<div class="col-sm-12 bg-box-red pdl_box_margin"><?php echo TABLE_HEADING_CART_EMPTY; ?></div>
<?php }else{?>

<?php
  $customers_query_raw = "select customers_id, customers_firstname, customers_lastname, customers_email_address from customers where customers_id in(" . implode(",", $cartlist) . ") order by customers_lastname, customers_firstname desc";
  $customers_query = tep_db_query($customers_query_raw);
  while ($customers = tep_db_fetch_array($customers_query)) {
  $customer_name = $customers['customers_firstname'] . ' ' . $customers['customers_lastname'];
  $customer_mail = $customers['customers_email_address'];

  $products_query = tep_db_query("select count(products_id) as total from customers_basket where customers_id = " . (int)$customers['customers_id']);
  $products = tep_db_fetch_array($products_query);
  $selected['count'] = $products['total'];
  $csct = $products['total'];

  $cart_data_query = tep_db_query("select * from customers_basket where customers_id = " . (int)$customers['customers_id']);
  $cdq = tep_db_fetch_array($cart_data_query);
  $ciddk = $cdq['customers_id'];
  $dr = substr($cdq['customers_basket_date_added'], 0, 4) . '-' . substr($cdq['customers_basket_date_added'], 4, 2) . '-' . substr($cdq['customers_basket_date_added'], 6, 2);

?>
<div class="col-sm-12 margin-box-inner">
<div class="row bg-box-blue">
<div class="col-sm-2 padding_inner"><?php echo $customer_name; ?></div>
<div class="col-sm-2 padding_inner"><?php echo TABLE_HEADING_CART_PROD_TOTAL . ' ' . $csct;?></div>
<div class="col-sm-2 padding_inner"><?php echo tep_date_short($dr);?></div>
<div class="col-sm-4 padding_inner"><?php echo $customer_mail; ?></div>
</div>

<?php
  $prod_query = tep_db_query("select * from customers_basket where customers_id = " . (int)$customers['customers_id']);
  while ($prod = tep_db_fetch_array($prod_query)) {
  $date_raw = substr($prod['customers_basket_date_added'], 0, 4) . '-' . substr($prod['customers_basket_date_added'], 4, 2) . '-' . substr($prod['customers_basket_date_added'], 6, 2);
  $prod_id = tep_get_prid($prod[products_id]);

  $name_query = tep_db_query("select pd.products_id, 
                                     pd.products_name name, 
                                     pd.products_description, 
                                     p.products_id,
                                     p.products_price,
                                     p.products_model model,
                                     p.products_image image,
                                     p.products_tax_class_id tcid,
                                     s.status,
                                     IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, 
                                     IF(s.status, s.specials_new_products_price, p.products_price) as final_price 
                                FROM " . TABLE_PRODUCTS . " p, 
                                     " . TABLE_PRODUCTS_DESCRIPTION . " pd 
                                     left join " . TABLE_SPECIALS . " s 
                                     on pd.products_id = s.products_id 
                               WHERE pd.products_id = '" . $prod_id . "' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "'");

  $pname = tep_db_fetch_array($name_query);

  $bsc_qty = $prod['customers_basket_quantity'];
  $price = $currencies->format($pname['final_price']);
  $sum_price = $price * $bsc_qty;

?>

<div class="row bg-box-yellow margin-box-inner">

<div class="col-sm-12">
<div class="col-sm-12">
<span class="text-box-head-inner"><?php echo $prod['customers_basket_quantity'] . ' x ' . $pname['name'] . '  <span class="text-box-smal-atovan-inner">| ' . TABLE_HEADING_PRODUCTS_SINGLE_PRICE . $currencies->display_price($price, tep_get_tax_rate($pname['tcid'])) . '</span>';?></span><br>
</div>
<div class="col-sm-12">
<?php
  $att_price_query = tep_db_query("select products_options_id, products_options_value_id from customers_basket_attributes where customers_id = " . (int)$customers['customers_id'] . " and products_id ='" . tep_db_input($prod['products_id']) . "'");
  $att_pr = tep_db_fetch_array($att_price_query);

  $attrib_pric = tep_db_query("select 
                                     pa.options_values_price,
                                     pa.price_prefix
                                from products_options popt, 
                                     products_options_values poval, 
                                     products_attributes pa 
                               where pa.products_id = '" . (int)$prod['products_id'] . "' and 
                                     pa.options_id = '" . (int)$att_pr['products_options_id'] . "' and 
                                     pa.options_id = popt.products_options_id and 
                                     pa.options_values_id = '" . (int)$att_pr['products_options_value_id'] . "' and 
                                     pa.options_values_id = poval.products_options_values_id");
                                     
  $atpric = tep_db_fetch_array($attrib_pric);
?>
<?php echo '<span class="text-quant-price">' . $bsc_qty . ' x ' . TABLE_HEADING_PRODUCTS_QUANTITY_PRICE . $currencies->display_price($sum_price, tep_get_tax_rate($pname['tcid'])) . '</span>';?>
</div>

<?php
  $att_query = tep_db_query("select products_options_id, products_options_value_id from customers_basket_attributes where customers_id = " . (int)$customers['customers_id'] . " and products_id ='" . tep_db_input($prod['products_id']) . "'");
  while ($att = tep_db_fetch_array($att_query)) {

  $attributes = tep_db_query("select 
                                     popt.products_options_name, 
                                     poval.products_options_values_name, 
                                     pa.options_values_price,
                                     pa.price_prefix
                                from products_options popt, 
                                     products_options_values poval, 
                                     products_attributes pa 
                               where pa.products_id = '" . (int)$prod['products_id'] . "' and 
                                     pa.options_id = '" . (int)$att['products_options_id'] . "' and 
                                     pa.options_id = popt.products_options_id and 
                                     pa.options_values_id = '" . (int)$att['products_options_value_id'] . "' and 
                                     pa.options_values_id = poval.products_options_values_id and 
                                     popt.language_id = '" . (int)$languages_id . "' and 
                                     poval.language_id = '" . (int)$languages_id . "'");
                                     
  $attrib = tep_db_fetch_array($attributes);
  $attributes_price = $currencies->format($attrib['options_values_price']);
  $att_price = $price * $bsc_qty;
  $att_sing_sum = $attrib['options_values_price'] * $bsc_qty;
  $att_sum = $attrib['options_values_price'] * $bsc_qty + $price * $bsc_qty;
?>

<?php if ($attrib['options_values_price'] == '0'){?>
<div class="col-sm-12"><?php if ($attrib['products_options_values_name'] > ' '){echo '<span class="text-box-aton-inner">' . $attrib['products_options_name'] . ': </span><span class="text-box-atovan-inner">' . $attrib['products_options_values_name'] . '</span><br>';}?></div>
<?php }else{ ?>
<div class="col-sm-12"><?php if ($attrib['products_options_values_name'] > ' '){echo '<span class="text-box-aton-inner">' . $attrib['products_options_name'] . ': </span><span class="text-box-atovan-inner">' . $attrib['products_options_values_name'] . '  </span><span class="text-box-smal-atovan-inner">( +' . $currencies->display_price($attributes_price, tep_get_tax_rate($pname['tcid'])) . ' )</span><br>';}?></div>

<div class="col-sm-12">
<?php echo '<span class="text-attrib-price">' . TABLE_HEADING_PRODUCTS_ATTRIBUTE_PRICE . '</span><span class="text-price-attrib">' . $currencies->format($att_sing_sum, tep_get_tax_rate($pname['tcid'])) . '</span>';?>
<?php echo tep_black_line(); ?>
<?php echo '<span class="text-total-price">' . TABLE_HEADING_PRODUCTS_TOTAL_PRICE . '</span><span class="text-price-total">' . $currencies->display_price($att_sum, tep_get_tax_rate($pname['tcid'])) . '</span>';?>
</div>
<?php }?>

<?php
 } // while ($att = tep_db_fetch_array($att_query)) {
?>
</div>


</div>

<?php } /* while ($prod = tep_db_fetch_array($prod_query)) { */ ?>

<?php echo tep_black_line(); ?>
</div>
<?php } /* while ($customers = tep_db_fetch_array($customers_query)) { */ ?>

<?php } /* }else{ */ ?>
<?php
  require('includes/template_bottom.php');
  require('includes/application_bottom.php');
?>

 

Edited by YePix

Share this post


Link to post
Share on other sites

final file.

Now everything works so far.

* Prices are displayed.
* Prices for attributes are displayed.
* The total price for individual shopping carts is displayed including the attribute prices.
* Total amount for all carts is displayed.

I have not installed the function to delete the shopping carts. If someone wants to do the work, please note that the session must also be deleted. Otherwise, the deleted products remain in the customer's shopping cart as long as the customer is logged in.

osCommerce Bootstrap 2.3.4-1 EDGE

 

<?php

  require('includes/application_top.php');
  require('includes/classes/' . 'currencies.php');
  $currencies = new currencies();

	$cid = (isset($_GET['cid']) ? $_GET['cid'] : '');
	$cartlist = array();
	$customers_query = tep_db_query("select distinct customers_id from customers_basket");
	while ($c = tep_db_fetch_array($customers_query)) $cartlist[] = $c['customers_id'];

  require('includes/template_top.php');
?>
<head>
<link rel="stylesheet" type="text/css" href="../ext/bootstrap/css/bootstrap.min.css">
</head>
<style>
.margin_inner{padding:2px;padding-left:8px;}
.pdl_box_margin{margin:10px;}
.margin-box-inner{padding-top:10px;padding-bottom:10px;padding-left:5px;padding-right:10px;}
.padding_inner{padding-top:6px;padding-bottom:6px;}
.box-border-dark{border:1px solid transparent;border-radius:2px;border-color:#666666;}
.bg-box-blue{background-color: #C6F3FF !important;border:1px solid transparent;border-radius:2px;border-color:#999999;}
.bg-box-green{background-color: #DFF0D8 !important;border:1px solid transparent;border-radius:2px;border-color:#61AA42;}
.bg-box-yellow{background-color: #FCF8E3 !important;border:1px solid transparent;border-radius:2px;border-color:#999999;}
.bg-box-red{background-color: #F2DEDE !important;border:1px solid transparent;border-radius:2px;border-color:#990000;}
.text-box-head-inner{color: #000000;font-size: 16px;font-weight:bold;}
.text-box-aton-inner{color: #FF0000;font-size: 12px;font-weight:bold;}
.text-box-atovan-inner{color: #000000;font-size: 12px;font-weight:bold;font-style: italic;}
.text-box-smal-atovan-inner{color: #000000;font-size: 10px;font-style: italic;}
.text-box-count-inner{color: #990000;font-weight:bold;font-style: italic;}
.text-box-center{text-align: center;}
.text-quant-price{color: #008CEA;font-size: 12px;font-weight:bold;}
.text-getfree-price{color: #990000;font-size: 14px;font-weight:bold;}
.text-attrib-price{color: #03A056;font-size: 12px;font-weight:bold;font-style: italic;}
.text-price-attrib{color: #008CEA;font-size: 12px;font-weight:bold;font-style: italic;}
.text-total-price{color: #000000;font-size: 16px;font-weight:bold;font-style: italic;}
.text-price-total{color: #008CEA;font-size: 16px;font-weight:bold;font-style: italic;}
.font-float-right{text-align: right}
.font-effect-shadow-multiple{}
</style>      
<div class="col-sm-12 pdl_box_margin pageHeading"><?php echo TABLE_HEADING_CART_TITLE; ?></div>
<?php if (empty($cartlist)) { ?>
<div class="col-sm-12 bg-box-red pdl_box_margin"><?php echo TABLE_HEADING_CART_EMPTY; ?></div>
<?php }else{?>

<?php
  $customers_query_raw = "select customers_id, customers_firstname, customers_lastname, customers_email_address from customers where customers_id in(" . implode(",", $cartlist) . ") order by customers_lastname, customers_firstname desc";
  $customers_query = tep_db_query($customers_query_raw);

  $totalAll = 0;
  
  while ($customers = tep_db_fetch_array($customers_query)) {
  $customer_name = $customers['customers_firstname'] . '&nbsp;' . $customers['customers_lastname'];
  $customer_mail = $customers['customers_email_address'];

  $products_query = tep_db_query("select count(products_id) as total from customers_basket where customers_id = " . (int)$customers['customers_id']);
  $products = tep_db_fetch_array($products_query);
  $selected['count'] = $products['total'];
  $bsk_count_qty = $products['customers_basket_quantity'];
  $csct = $products['total'];

  $cart_data_query = tep_db_query("select * from customers_basket where customers_id = " . (int)$customers['customers_id']);
  $cdq = tep_db_fetch_array($cart_data_query);
  $ciddk = $cdq['customers_id'];
  $dr = substr($cdq['customers_basket_date_added'], 0, 4) . '-' . substr($cdq['customers_basket_date_added'], 4, 2) . '-' . substr($cdq['customers_basket_date_added'], 6, 2);

?>
<div class="col-sm-12 margin-box-inner">

<div class="col-sm-12 bg-box-blue">
<div class="row bg-box-blue">
<div class="col-sm-4 padding_inner"><?php echo $customer_name; ?></div>
<div class="col-sm-4 padding_inner"><?php echo TABLE_HEADING_CART_PROD_TOTAL . '&nbsp;' . $csct;?></div>
<div class="col-sm-4 padding_inner"><?php echo tep_date_short($dr);?></div>
</div>

<?php
  $prod_query = tep_db_query("select * from customers_basket where customers_id = " . (int)$customers['customers_id']);

  $sum_price = 0;
  $sum_prod_price = 0;
  $attributes_price = 0;
  $attrib_sum_price = 0;

  while ($prod = tep_db_fetch_array($prod_query)) {
  $date_raw = substr($prod['customers_basket_date_added'], 0, 4) . '-' . substr($prod['customers_basket_date_added'], 4, 2) . '-' . substr($prod['customers_basket_date_added'], 6, 2);
  $prod_id = tep_get_prid($prod[products_id]);

  $name_query = tep_db_query("select pd.products_id, 
                                     pd.products_name name, 
                                     pd.products_description, 
                                     p.products_id,
                                     p.products_price,
                                     p.products_model model,
                                     p.products_image image,
                                     p.products_tax_class_id tcid,
                                     s.status,
                                     IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, 
                                     IF(s.status, s.specials_new_products_price, p.products_price) as final_price 
                                FROM " . TABLE_PRODUCTS . " p, 
                                     " . TABLE_PRODUCTS_DESCRIPTION . " pd 
                                     left join " . TABLE_SPECIALS . " s 
                                     on pd.products_id = s.products_id 
                               WHERE pd.products_id = '" . $prod_id . "' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "'");

  $pname = tep_db_fetch_array($name_query);

  $price = $pname['final_price'];
  $bsk_qty = $prod['customers_basket_quantity'];
  $sum_price = $sum_price + ($bsk_qty * $price);
  $sum_prod_price = $currencies->format($pname['final_price'] * $prod['customers_basket_quantity']);

?>
<div class="row bg-box-yellow margin-box-inner">

<div class="col-sm-5">
<span class="text-box-head-inner"><?php echo $prod['customers_basket_quantity'] . ' x ' . $pname['name'] . '&nbsp;&nbsp;|&nbsp;' . $currencies->display_price($sum_prod_price, tep_get_tax_rate($pname['tcid']));?></span><br>
</div>

<?php
  $att_query = tep_db_query("select products_options_id, products_options_value_id from customers_basket_attributes where customers_id = " . (int)$customers['customers_id'] . " and products_id ='" . tep_db_input($prod['products_id']) . "'");

  while ($att = tep_db_fetch_array($att_query)) {

  $attributes = tep_db_query("select 
                                     popt.products_options_name, 
                                     poval.products_options_values_name, 
                                     pa.options_values_price,
                                     pa.price_prefix
                                from products_options popt, 
                                     products_options_values poval, 
                                     products_attributes pa 
                               where pa.products_id = '" . (int)$prod['products_id'] . "' and 
                                     pa.options_id = '" . (int)$att['products_options_id'] . "' and 
                                     pa.options_id = popt.products_options_id and 
                                     pa.options_values_id = '" . (int)$att['products_options_value_id'] . "' and 
                                     pa.options_values_id = poval.products_options_values_id and 
                                     popt.language_id = '" . (int)$languages_id . "' and 
                                     poval.language_id = '" . (int)$languages_id . "'");
                                     
  $attrib = tep_db_fetch_array($attributes);
  $attributes_price = $attrib['options_values_price']; // Preisanzeige für einzelne Attribute
  $attrib_sum_price += $currencies->format($attributes_price * $bsk_qty);
?>
<?php if ($attrib['options_values_price'] == '0'){?>
<div class="col-sm-12"><span class="text-box-head-inner"><?php if ($attrib['products_options_values_name'] > ' '){echo '<span class="text-box-aton-inner">' . $attrib['products_options_name'] . ': </span><span class="text-box-atovan-inner">' . $attrib['products_options_values_name'] . '</span><br>';}?></span></div>
<?php }else{ ?>
<div class="col-sm-12"><span class="text-box-head-inner"><?php if ($attrib['products_options_values_name'] > ' '){echo '<span class="text-box-aton-inner">' . $attrib['products_options_name'] . ': </span><span class="text-box-atovan-inner">' . $attrib['products_options_values_name'] . '&nbsp;&nbsp;</span><span class="text-box-smal-atovan-inner">( +' . $currencies->display_price($attributes_price, tep_get_tax_rate($pname['tcid'])) . '&nbsp;)</span><br>';}?></span></div>
<?php 
 }
} // while ($att = tep_db_fetch_array($att_query)) {
?>

</div><!-- Zeile 68 <div class="col-sm-12 margin-box-inner"> -->
<?php } /* while ($prod = tep_db_fetch_array($prod_query)) { */ ?>

<div class="col-sm-5 text-box-head-inner margin-box-inner">
<?php 

?>
<?php 
$totalAll += $sum_price + $attrib_sum_price;
$tcart_formated = $currencies->format($sum_price + $attrib_sum_price);
echo TABLE_HEADING_BASKET_TOTAL_PRICE . '' . $currencies->display_price($tcart_formated, tep_get_tax_rate($pname['tcid']));?>
</div>

</div>
</div>

<?php echo tep_black_line(); ?>
<?php } /* while ($customers = tep_db_fetch_array($customers_query)) { */ ?>
<div class="col-sm-12 text-box-head-inner margin-box-inner bg-box-red font-float-right">
<?php
$totalAll_formated = $currencies->format($totalAll); 
echo TABLE_HEADING_BASKET_TOTAL_PRICE . '' . $currencies->display_price($totalAll_formated, tep_get_tax_rate($pname['tcid']));?>
</div>

<?php } /* }else{ */ ?>
<?php
  require('includes/template_bottom.php');
  require('includes/application_bottom.php');
?>

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×