Jump to content
Sign in to follow this  
redrum

Impulse Item

Recommended Posts

I uploaded a new contribution, Impulse Item;

http://www.oscommerce.com/community/contributions,3689

 

This contrib adds one or several impulse items to your shopping cart, and in the checkout process. This is used to increase your sales and running special offers.

 

This is in alpha status and should be tested before you run it on a live shop. But do try it and improve it.

 

Screenshots included.

 

// Fredrik

Share this post


Link to post
Share on other sites

Hi Fredrik

 

I've been looking for a contrib like this for quite a while - great idea.

 

I'd just like to check before trying it out...if I use it, will I be able to use specials normally or will I only be able to use one or the other?

 

Also - is there a list of the modifications in the specials.php files rather than just uploading them? I'm not too sure what differences there are in my current specials.php and I'd hate to break it.

 

Thanks

 

M.

Share this post


Link to post
Share on other sites

Great contribution, except it doesnt say the old price w/ the new price and it doesnt say "limited time, expires__" or anything but yet it asked me to fill that info out?

Share this post


Link to post
Share on other sites
I'd just like to check before trying it out...if I use it, will I be able to use specials normally or will I only be able to use one or the other?

Impulse Item is a stand alone function, so you will still be able to use specials normally.

 

Also - is there a list of the modifications in the specials.php files rather than just uploading them? I'm not too sure what differences there are in my current specials.php and I'd hate to break it.

You will not overwrite your specials.php, you don't even have to edit that file at all. The actually file that shows the impulse items is a new file and it is called specials_checkout.php

But as for the other files there is a readme-file of what you have to edit.

 

// Fredrik

Share this post


Link to post
Share on other sites
Great contribution, except it doesnt say the old price w/ the new price and it doesnt say "limited time, expires__" or anything but yet it asked me to fill that info out?

Since it rather is a impulse item-function instead of a specials-function I thought that it wasn't necessary to show the regular price.

But you can easily add it if you want to, just compare OSC's original file specials.php with mine specials_checkout.php and you should be able to add the regular price.

 

As for the limited time, I don't want to list that since I wanted to keep it as slim as possible. Again its a impulse item-function. But it might be nice to able to set a limited time in admin for the product if you want that.

But you should be able to add this as well, if you want to. I haven't looked into it thou.

 

// Fredrik

Share this post


Link to post
Share on other sites

Great contribution, thank you. The only problem that I've found occurs if you don't have any products set as impulse items. Then I get this error on my checkout_shipping page:

 

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-21, 21' at line 1

 

select p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, p.products_image, s.specials_new_products_price from products p, products_description pd, specials_checkout s where s.products_id = p.products_id and p.products_id = pd.products_id and pd.language_id = '1' and s.status = '1' order by s.specials_date_added DESC limit -21, 21

 

Any ideas?


Sign Here

Share this post


Link to post
Share on other sites
Great contribution, thank you. The only problem that I've found occurs if you don't have any products set as impulse items. Then I get this error on my checkout_shipping page:

 

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-21, 21' at line 1

 

Any ideas?

 

I got that error myself in my demo shop, and it is a problem with MySQL 4.1 and osCommerce.

Check this post to solve this:

http://forums.oscommerce.com/index.php?sho...26entry697026

 

(many thanks to vger for this)

 

// Fredrik

Share this post


Link to post
Share on other sites

I had already done that to fix a previous problem. The syntax error is showing up in the shopping cart, not on the admin side. Hmm..


Sign Here

Share this post


Link to post
Share on other sites
I had already done that to fix a previous problem. The syntax error is showing up in the shopping cart, not on the admin side. Hmm..

 

Do the same changes in catalog/includes/classes/split_page_results.php as well, then it should work.

 

// Fredrik

Share this post


Link to post
Share on other sites

Howdy Redrum

 

Great contribution! :D

 

I am testing it now.

 

I am running it with along with Dangling Carrot 2.0

 

I have a couple questions:

 

When I select the Special Offer at checkout, it shows up in the Shopping Cart at it's regular price.

 

For example, regular price is $49.95, I give it a Specials Offer price as $39.95. It shows up accurately at $39.95, yet when I Buy It Now, it shows up in the Cart as $49.95. Why?

 

Let me know if you know.

 

Best, Ted

Share this post


Link to post
Share on other sites
Howdy Redrum

 

Great contribution! :D

 

I am testing it now.

 

I am running it with along with Dangling Carrot 2.0

 

I have a couple questions:

 

When I select the Special Offer at checkout, it shows up in the Shopping Cart at it's regular price.

 

For example, regular price is $49.95, I give it a Specials Offer price as $39.95. It shows up accurately at $39.95, yet when I Buy It Now, it shows up in the Cart as $49.95. Why?

 

Let me know if you know.

 

Best, Ted

I think you might forgot to include the code in

catalog/includes/classes/shopping_cart.php or/and catalog/admin/includes/classes/shopping_cart.php

Check those files with the README-file in the contrib.

 

As for Dangling Carrot 2.0, its a nice contrib, unfortunately you are limited to only one item. A contrib that combine the functions in these to contribs would be the ultimate.

 

btw, please let me know if these two contribs increases your sales.

 

// Fredrik

Share this post


Link to post
Share on other sites

Howdy Fredrik

 

Oh yes, combining this with Dangling Carrot would be a fantastic tool, and yes, I am sure it will bring in more sales; however, I have not tested your contribution on a live site yet.

 

I think you might forgot to include the code in

catalog/includes/classes/shopping_cart.php or/and catalog/admin/includes/classes/shopping_cart.php

Check those files with the README-file in the contrib.

 

As for Dangling Carrot 2.0, its a nice contrib, unfortunately you are limited to only one item. A contrib that combine the functions in these to contribs would be the ultimate.

 

btw, please let me know if these two contribs increases your sales.

 

// Fredrik

 

Actually, on my catalog side, the following code:

 

$specials_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . (int)$prid . "' and status = '1'");
	  if (tep_db_num_rows ($specials_query)) {
		$specials = tep_db_fetch_array($specials_query);
		$products_price = $specials['specials_new_products_price'];
	  }

 

is in my functions/general.php file.

 

Also, your instructions have this marked twice:

 

==================================================
3. Open catalog/includes/classes/shopping_cart.php
==================================================

FIND:
$specials_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . (int)$prid . "' and status = '1'");
	  if (tep_db_num_rows ($specials_query)) {
		$specials = tep_db_fetch_array($specials_query);
		$products_price = $specials['specials_new_products_price'];
	  }

ADD AFTER:
//Impulse Item by jfj
$specials_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS_CHECKOUT . " where products_id = '" . (int)$prid . "' and status = '1'");
	  if (tep_db_num_rows ($specials_query)) {
		$specials = tep_db_fetch_array($specials_query);
		$products_price = $specials['specials_new_products_price'];
	  }
//Impulse Item by jfj	



FIND:
$specials_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . (int)$prid . "' and status = '1'");
	  if (tep_db_num_rows($specials_query)) {
		$specials = tep_db_fetch_array($specials_query);
		$products_price = $specials['specials_new_products_price'];
	  }

ADD AFTER:
//Impulse Item by jfj
	  $specials_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS_CHECKOUT . " where products_id = '" . (int)$prid . "' and status = '1'");
	  if (tep_db_num_rows($specials_query)) {
		$specials = tep_db_fetch_array($specials_query);
		$products_price = $specials['specials_new_products_price'];
	  }
//Impulse Item by jfj

 

However, I only find it once.

 

My catalog/includes/classes/shopping_cart.php looks like this (sorry it is so long):

 

<?php
/*
 $Id: shopping_cart.php,v 1.1.1.1 2004/03/04 23:40:47 ccwjr Exp $

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

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

 class shoppingCart {
var $contents, $total, $weight, $cartID, $content_type;

function shoppingCart() {
  $this->reset();
}

function restore_contents() {
//ICW replace line
  global $customer_id, $gv_id, $REMOTE_ADDR;
//	  global $customer_id;

  if (!tep_session_is_registered('customer_id')) return false;

// insert current cart contents in database
  if (is_array($this->contents)) {
	reset($this->contents);
	while (list($products_id, ) = each($this->contents)) {
	  $qty = $this->contents[$products_id]['qty'];
	  $product_query = tep_db_query("select products_id from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'");
	  if (!tep_db_num_rows($product_query)) {
		tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET . " (customers_id, products_id, customers_basket_quantity, customers_basket_date_added) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . $qty . "', '" . date('Ymd') . "')");
		if (isset($this->contents[$products_id]['attributes'])) {
		  reset($this->contents[$products_id]['attributes']);
		  while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {
			// otf 1.71 Update query to include attribute value. This is needed for text attributes.
			$attr_value = $this->contents[$products_id]['attributes_values'][$option];
			tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id, products_options_value_text) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . (int)$option . "', '" . (int)$value . "', '" . tep_db_input($attr_value) . "')");
		  }
		}
	  } else {
		tep_db_query("update " . TABLE_CUSTOMERS_BASKET . " set customers_basket_quantity = '" . $qty . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'");
	  }
	}
//ICW ADDDED FOR CREDIT CLASS GV - START
	if (tep_session_is_registered('gv_id')) {
	  $gv_query = tep_db_query("insert into  " . TABLE_COUPON_REDEEM_TRACK . " (coupon_id, customer_id, redeem_date, redeem_ip) values ('" . $gv_id . "', '" . (int)$customer_id . "', now(),'" . $REMOTE_ADDR . "')");
	  $gv_update = tep_db_query("update " . TABLE_COUPONS . " set coupon_active = 'N' where coupon_id = '" . $gv_id . "'");
	  tep_gv_account_update($customer_id, $gv_id);
	  tep_session_unregister('gv_id');
	}
//ICW ADDDED FOR CREDIT CLASS GV - END
  }

// reset per-session cart contents, but not the database contents
  $this->reset(false);

  $products_query = tep_db_query("select products_id, customers_basket_quantity from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "'");
  while ($products = tep_db_fetch_array($products_query)) {
	$this->contents[$products['products_id']] = array('qty' => $products['customers_basket_quantity']);
// attributes
// otf 1.71Update query to pull attribute value_text. This is needed for text attributes.
	$attributes_query = tep_db_query("select products_options_id, products_options_value_id, products_options_value_text from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products['products_id']) . "'");
	while ($attributes = tep_db_fetch_array($attributes_query)) {
	  $this->contents[$products['products_id']]['attributes'][$attributes['products_options_id']] = $attributes['products_options_value_id'];
	  // If text attribute, then set additional information
	  if ($attributes['products_options_value_id'] == PRODUCTS_OPTIONS_VALUE_TEXT_ID) {
		$this->contents[$products['products_id']]['attributes_values'][$attributes['products_options_id']] = $attributes['products_options_value_text'];
	  }
	}
  }

  $this->cleanup();
}

function reset($reset_database = false) {
  global $customer_id;

  $this->contents = array();
  $this->total = 0;
  $this->weight = 0;
  $this->content_type = false;

  if (tep_session_is_registered('customer_id') && ($reset_database == true)) {
	tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "'");
	tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "'");
  }

  unset($this->cartID);
  if (tep_session_is_registered('cartID')) tep_session_unregister('cartID');
}

function add_cart($products_id, $qty = '1', $attributes = '', $notify = true) {
  global $new_products_id_in_cart, $customer_id;

  $products_id = tep_get_uprid($products_id, $attributes);
  if ($notify == true) {
	$new_products_id_in_cart = $products_id;
	tep_session_register('new_products_id_in_cart');
  }

  if ($this->in_cart($products_id)) {
	$this->update_quantity($products_id, $qty, $attributes);
  } else {
	$this->contents[] = array($products_id);
	$this->contents[$products_id] = array('qty' => $qty);
// insert into database
	if (tep_session_is_registered('customer_id')) tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET . " (customers_id, products_id, customers_basket_quantity, customers_basket_date_added) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . $qty . "', '" . date('Ymd') . "')");

	if (is_array($attributes)) {
	  reset($attributes);
	  while (list($option, $value) = each($attributes)) {
// otf 1.71 Check if input was from text box.  If so, store additional attribute information
		// Check if text input is blank, if so do not add to attribute lists
		// Add htmlspecialchars processing.  This handles quotes and other special chars in the user input.
		$attr_value = NULL;
		$blank_value = FALSE;
		if (strstr($option, TEXT_PREFIX)) {
		  if (trim($value) == NULL)
		  {
			$blank_value = TRUE;
		  } else {
			$option = substr($option, strlen(TEXT_PREFIX));
			$attr_value = htmlspecialchars(stripslashes($value), ENT_QUOTES);
			$value = PRODUCTS_OPTIONS_VALUE_TEXT_ID;
			$this->contents[$products_id]['attributes_values'][$option] = $attr_value;
		  }
		}
		if (!$blank_value)
		{
		  $this->contents[$products_id]['attributes'][$option] = $value;
// insert into database
// otf 1.71 Update db insert to include attribute value_text. This is needed for text attributes.
		// Add tep_db_input() processing
		  if (tep_session_is_registered('customer_id')) tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id, products_options_value_text) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . (int)$option . "', '" . (int)$value . "', '" . tep_db_input($attr_value) . "')");
		}
	  }
	}
  }
  $this->cleanup();

// assign a temporary unique ID to the order contents to prevent hack attempts during the checkout procedure
  $this->cartID = $this->generate_cart_id();
}

function update_quantity($products_id, $quantity = '', $attributes = '') {
  global $customer_id;

  if (empty($quantity)) return true; // nothing needs to be updated if theres no quantity, so we return true..

  $this->contents[$products_id] = array('qty' => $quantity);
// update database
  if (tep_session_is_registered('customer_id')) tep_db_query("update " . TABLE_CUSTOMERS_BASKET . " set customers_basket_quantity = '" . $quantity . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'");

  if (is_array($attributes)) {
	reset($attributes);
	while (list($option, $value) = each($attributes)) {
// otf 1.71 Check if input was from text box.  If so, store additional attribute information
	  // Check if text input is blank, if so do not update attribute lists
	  // Add htmlspecialchars processing.  This handles quotes and other special chars in the user input.
	  $attr_value = NULL;
	  $blank_value = FALSE;
	  if (strstr($option, TEXT_PREFIX)) {
		if (trim($value) == NULL)
		{
		  $blank_value = TRUE;
		} else {
		  $option = substr($option, strlen(TEXT_PREFIX));
		  $attr_value = htmlspecialchars(stripslashes($value), ENT_QUOTES);
		  $value = PRODUCTS_OPTIONS_VALUE_TEXT_ID;
		  $this->contents[$products_id]['attributes_values'][$option] = $attr_value;
		}
	  }

	  if (!$blank_value)
	  {
		$this->contents[$products_id]['attributes'][$option] = $value;
// update database
		// Update db insert to include attribute value_text. This is needed for text attributes.
		// Add tep_db_input() processing
		if (tep_session_is_registered('customer_id')) tep_db_query("update " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " set products_options_value_id = '" . (int)$value . "', products_options_value_text = '" . tep_db_input($attr_value) . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "' and products_options_id = '" . (int)$option . "'");
	  }
	}
  }
}

function cleanup() {
  global $customer_id;

  reset($this->contents);
  while (list($key,) = each($this->contents)) {
	if ($this->contents[$key]['qty'] < 1) {
	  unset($this->contents[$key]);
// remove from database
	  if (tep_session_is_registered('customer_id')) {
		tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($key) . "'");
		tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($key) . "'");
	  }
	}
  }
}

function count_contents() {  // get total number of items in cart
  $total_items = 0;
  if (is_array($this->contents)) {
	reset($this->contents);
	while (list($products_id, ) = each($this->contents)) {
	  $total_items += $this->get_quantity($products_id);
	}
  }

  return $total_items;
}

function get_quantity($products_id) {
  if (isset($this->contents[$products_id])) {
	return $this->contents[$products_id]['qty'];
  } else {
	return 0;
  }
}

function in_cart($products_id) {
  if (isset($this->contents[$products_id])) {
	return true;
  } else {
	return false;
  }
}

function remove($products_id) {
  global $customer_id;
// otf 1.71 Add call tep_get_uprid to correctly format product ids containing quotes
  $products_id = tep_get_uprid($products_id, $attributes);

  unset($this->contents[$products_id]);
// remove from database
  if (tep_session_is_registered('customer_id')) {
	tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'");
	tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'");
  }

// assign a temporary unique ID to the order contents to prevent hack attempts during the checkout procedure
  $this->cartID = $this->generate_cart_id();
}

function remove_all() {
  $this->reset();
}

function get_product_id_list() {
  $product_id_list = '';
  if (is_array($this->contents)) {
	reset($this->contents);
	while (list($products_id, ) = each($this->contents)) {
	  $product_id_list .= ', ' . $products_id;
	}
  }

  return substr($product_id_list, 2);
}

function calculate() {
  $this->total_virtual = 0; // ICW Gift Voucher System
  $this->total = 0;
  $this->weight = 0;
  if (!is_array($this->contents)) return 0;

  reset($this->contents);
  while (list($products_id, ) = each($this->contents)) {
	$qty = $this->contents[$products_id]['qty'];

// products price
	$product_query = tep_db_query("select products_id, products_price, products_tax_class_id, products_weight from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");
	if ($product = tep_db_fetch_array($product_query)) {
// ICW ORDER TOTAL CREDIT CLASS Start Amendment
	  $no_count = 1;
	  $gv_query = tep_db_query("select products_model from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");
	  $gv_result = tep_db_fetch_array($gv_query);
	  if (ereg('^GIFT', $gv_result['products_model'])) {
		$no_count = 0;
	  }
// ICW ORDER TOTAL  CREDIT CLASS End Amendment
	  $prid = $product['products_id'];
	  $products_tax = tep_get_tax_rate($product['products_tax_class_id']);
	  $products_price = $product['products_price'];
	  $products_weight = $product['products_weight'];

	  $special_price = tep_get_products_special_price($prid);
	  if ($special_price) {
		$products_price = $special_price;
	  }
	  $this->total_virtual += tep_add_tax($products_price, $products_tax) * $qty * $no_count;// ICW CREDIT CLASS;
	  $this->weight_virtual += ($qty * $products_weight) * $no_count;// ICW CREDIT CLASS;
	  $this->total += tep_add_tax($products_price, $products_tax) * $qty;
	  $this->weight += ($qty * $products_weight);
	}

// attributes price
	if (isset($this->contents[$products_id]['attributes'])) {
	  reset($this->contents[$products_id]['attributes']);
	  while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {
		$attribute_price_query = tep_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$prid . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'");
		$attribute_price = tep_db_fetch_array($attribute_price_query);
		if ($attribute_price['price_prefix'] == '+') {
		  $this->total += $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax);
		} else {
		  $this->total -= $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax);
		}
	  }
	}
  }
}

function attributes_price($products_id) {
  $attributes_price = 0;

  if (isset($this->contents[$products_id]['attributes'])) {
	reset($this->contents[$products_id]['attributes']);
	while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {
	  $attribute_price_query = tep_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$products_id . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'");
	  $attribute_price = tep_db_fetch_array($attribute_price_query);
	  if ($attribute_price['price_prefix'] == '+') {
		$attributes_price += $attribute_price['options_values_price'];
	  } else {
		$attributes_price -= $attribute_price['options_values_price'];
	  }
	}
  }

  return $attributes_price;
}

function get_products() {
  global $languages_id;

  if (!is_array($this->contents)) return false;

  $products_array = array();
  reset($this->contents);
  while (list($products_id, ) = each($this->contents)) {
//		$products_query = tep_db_query("select p.products_id, pd.products_name, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_tax_class_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$products_id . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");

	  $products_query = tep_db_query("select p.products_id, pd.products_name, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_carrot, p.products_tax_class_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$products_id . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");

	if ($products = tep_db_fetch_array($products_query)) {
	  $prid = $products['products_id'];
	  $products_price = $products['products_price'];

	  $special_price = tep_get_products_special_price($prid);
	  if ($special_price) {
		$products_price = $special_price;
	  }

// otf 1.71 Update $products_array to include attribute value_text. This is needed for text attributes.
	  $products_array[] = array('id' => $products_id,
								'name' => $products['products_name'],
								'model' => $products['products_model'],
								'image' => $products['products_image'],
								'price' => $products_price,
								'quantity' => $this->contents[$products_id]['qty'],
								'weight' => $products['products_weight'],
								'carrot' => $products['products_carrot'],
								'final_price' => ($products_price + $this->attributes_price($products_id)),
								'tax_class_id' => $products['products_tax_class_id'],
								'attributes' => (isset($this->contents[$products_id]['attributes']) ? $this->contents[$products_id]['attributes'] : ''),
								'attributes_values' => (isset($this->contents[$products_id]['attributes_values']) ? $this->contents[$products_id]['attributes_values'] : ''));
	}
  }

  return $products_array;
}

function show_total() {
  $this->calculate();

  return $this->total;
}

function show_weight() {
  $this->calculate();

  return $this->weight;
}
// CREDIT CLASS Start Amendment
function show_total_virtual() {
  $this->calculate();

  return $this->total_virtual;
}

function show_weight_virtual() {
  $this->calculate();

  return $this->weight_virtual;
}
// CREDIT CLASS End Amendment

function generate_cart_id($length = 5) {
  return tep_create_random_value($length, 'digits');
}

function get_content_type() {
  $this->content_type = false;

  if ( (DOWNLOAD_ENABLED == 'true') && ($this->count_contents() > 0) ) {
	reset($this->contents);
	while (list($products_id, ) = each($this->contents)) {
	  if (isset($this->contents[$products_id]['attributes'])) {
		reset($this->contents[$products_id]['attributes']);
		while (list(, $value) = each($this->contents[$products_id]['attributes'])) {
		  $virtual_check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad where pa.products_id = '" . (int)$products_id . "' and pa.options_values_id = '" . (int)$value . "' and pa.products_attributes_id = pad.products_attributes_id");
		  $virtual_check = tep_db_fetch_array($virtual_check_query);

		  if ($virtual_check['total'] > 0) {
			switch ($this->content_type) {
			  case 'physical':
				$this->content_type = 'mixed';

				return $this->content_type;
				break;
			  default:
				$this->content_type = 'virtual';
				break;
			}
		  } else {
			switch ($this->content_type) {
			  case 'virtual':
				$this->content_type = 'mixed';

				return $this->content_type;
				break;
			  default:
				$this->content_type = 'physical';
				break;
			}
		  }
		}
// ICW ADDED CREDIT CLASS - Begin
	  } elseif ($this->show_weight() == 0) {
		reset($this->contents);
		while (list($products_id, ) = each($this->contents)) {
		  $virtual_check_query = tep_db_query("select products_weight from " . TABLE_PRODUCTS . " where products_id = '" . $products_id . "'");
		  $virtual_check = tep_db_fetch_array($virtual_check_query);
		  if ($virtual_check['products_weight'] == 0) {
			switch ($this->content_type) {
			  case 'physical':
				$this->content_type = 'mixed';

				return $this->content_type;
				break;
			  default:
				$this->content_type = 'virtual_weight';
				break;
			}
		  } else {
			switch ($this->content_type) {
			  case 'virtual':
				$this->content_type = 'mixed';

				return $this->content_type;
				break;
			  default:
				$this->content_type = 'physical';
				break;
			}
		  }
		}
// ICW ADDED CREDIT CLASS - End
	  } else {
		switch ($this->content_type) {
		  case 'virtual':
			$this->content_type = 'mixed';

			return $this->content_type;
			break;
		  default:
			$this->content_type = 'physical';
			break;
		}
	  }
	}
  } else {
	$this->content_type = 'physical';
  }

  return $this->content_type;
}

function unserialize($broken) {
  for(reset($broken);$kv=each($broken);) {
	$key=$kv['key'];
	if (gettype($this->$key)!="user function")
	$this->$key=$kv['value'];
  }
}
  // ------------------------ ICWILSON CREDIT CLASS Gift Voucher Addittion-------------------------------Start
  // amend count_contents to show nil contents for shipping
  // as we don't want to quote for 'virtual' item
  // GLOBAL CONSTANTS if NO_COUNT_ZERO_WEIGHT is true then we don't count any product with a weight
  // which is less than or equal to MINIMUM_WEIGHT
  // otherwise we just don't count gift certificates

function count_contents_virtual() {  // get total number of items in cart disregard gift vouchers
  $total_items = 0;
  if (is_array($this->contents)) {
	reset($this->contents);
	while (list($products_id, ) = each($this->contents)) {
	  $no_count = false;
	  $gv_query = tep_db_query("select products_model from " . TABLE_PRODUCTS . " where products_id = '" . $products_id . "'");
	  $gv_result = tep_db_fetch_array($gv_query);
	  if (ereg('^GIFT', $gv_result['products_model'])) {
		$no_count=true;
	  }
	  if (NO_COUNT_ZERO_WEIGHT == 1) {
		$gv_query = tep_db_query("select products_weight from " . TABLE_PRODUCTS . " where products_id = '" . tep_get_prid($products_id) . "'");
		$gv_result=tep_db_fetch_array($gv_query);
		if ($gv_result['products_weight']<=MINIMUM_WEIGHT) {
		  $no_count=true;
		}
	  }
	  if (!$no_count) $total_items += $this->get_quantity($products_id);
	}
  }
  return $total_items;
}
// ------------------------ ICWILSON CREDIT CLASS Gift Voucher Addittion-------------------------------End
 }
?>

 

The section in my catalog/includes/functions/general.php looks thus:

 

////
// Return a product's special price (returns nothing if there is no offer)
// TABLES: products
 function tep_get_products_special_price($product_id) {
$product_query = tep_db_query("select products_price, products_model from " . TABLE_PRODUCTS . " where products_id = '" . $product_id . "'");
if (tep_db_num_rows($product_query)) {
  $product = tep_db_fetch_array($product_query);
	  $product_price = $product['products_price'];
} else {
	  return false;
}

$specials_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . $product_id . "' and status");
if (tep_db_num_rows($specials_query)) {
  $special = tep_db_fetch_array($specials_query);
	  $special_price = $special['specials_new_products_price'];
} else {
	  $special_price = false;
}
//Impulse Item by jfj
	  $specials_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS_CHECKOUT . " where products_id = '" . (int)$prid . "' and status = '1'");
	  if (tep_db_num_rows($specials_query)) {
		$specials = tep_db_fetch_array($specials_query);
		$products_price = $specials['specials_new_products_price'];
	  }
//Impulse Item by jfj

if(substr($product['products_model'], 0, 4) == 'GIFT') {	//Never apply a salededuction to Ian Wilson's Giftvouchers
  return $special_price;
}

$product_to_categories_query = tep_db_query("select categories_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . $product_id . "'");
$product_to_categories = tep_db_fetch_array($product_to_categories_query);

 

Any ideas?

 

By the way, my regular speicals.php works fine, and the correct specials_checkout.php price is being added to the database.

 

Best Regards, Ted

Share this post


Link to post
Share on other sites
By the way, my regular speicals.php works fine, and the correct specials_checkout.php price is being added to the database.

 

Best Regards, Ted

Hey Ted,

 

I took a look at your catalog/includes/classes/shopping_cart.php and compared it with mine. And your code is abit different from mine, so it's not easy for you to find where to add it.

 

So try first with this code, acctually I have no idea if it will work. But let try it out, and let me know how it works out for you.

<?php
/*
$Id: shopping_cart.php,v 1.1.1.1 2004/03/04 23:40:47 ccwjr Exp $

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

Copyright (c) 2003 osCommerce

Released under the GNU General Public License
*/

class shoppingCart {
var $contents, $total, $weight, $cartID, $content_type;

function shoppingCart() {
$this->reset();
}

function restore_contents() {
//ICW replace line
global $customer_id, $gv_id, $REMOTE_ADDR;
// global $customer_id;

if (!tep_session_is_registered('customer_id')) return false;

// insert current cart contents in database
if (is_array($this->contents)) {
reset($this->contents);
while (list($products_id, ) = each($this->contents)) {
$qty = $this->contents[$products_id]['qty'];
$product_query = tep_db_query("select products_id from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'");
if (!tep_db_num_rows($product_query)) {
tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET . " (customers_id, products_id, customers_basket_quantity, customers_basket_date_added) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . $qty . "', '" . date('Ymd') . "')");
if (isset($this->contents[$products_id]['attributes'])) {
reset($this->contents[$products_id]['attributes']);
while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {
// otf 1.71 Update query to include attribute value. This is needed for text attributes.
$attr_value = $this->contents[$products_id]['attributes_values'][$option];
tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id, products_options_value_text) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . (int)$option . "', '" . (int)$value . "', '" . tep_db_input($attr_value) . "')");
}
}
} else {
tep_db_query("update " . TABLE_CUSTOMERS_BASKET . " set customers_basket_quantity = '" . $qty . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'");
}
}
//ICW ADDDED FOR CREDIT CLASS GV - START
if (tep_session_is_registered('gv_id')) {
$gv_query = tep_db_query("insert into " . TABLE_COUPON_REDEEM_TRACK . " (coupon_id, customer_id, redeem_date, redeem_ip) values ('" . $gv_id . "', '" . (int)$customer_id . "', now(),'" . $REMOTE_ADDR . "')");
$gv_update = tep_db_query("update " . TABLE_COUPONS . " set coupon_active = 'N' where coupon_id = '" . $gv_id . "'");
tep_gv_account_update($customer_id, $gv_id);
tep_session_unregister('gv_id');
}
//ICW ADDDED FOR CREDIT CLASS GV - END
}

// reset per-session cart contents, but not the database contents
$this->reset(false);

$products_query = tep_db_query("select products_id, customers_basket_quantity from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "'");
while ($products = tep_db_fetch_array($products_query)) {
$this->contents[$products['products_id']] = array('qty' => $products['customers_basket_quantity']);
// attributes
// otf 1.71Update query to pull attribute value_text. This is needed for text attributes.
$attributes_query = tep_db_query("select products_options_id, products_options_value_id, products_options_value_text from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products['products_id']) . "'");
while ($attributes = tep_db_fetch_array($attributes_query)) {
$this->contents[$products['products_id']]['attributes'][$attributes['products_options_id']] = $attributes['products_options_value_id'];
// If text attribute, then set additional information
if ($attributes['products_options_value_id'] == PRODUCTS_OPTIONS_VALUE_TEXT_ID) {
$this->contents[$products['products_id']]['attributes_values'][$attributes['products_options_id']] = $attributes['products_options_value_text'];
}
}
}

$this->cleanup();
}

function reset($reset_database = false) {
global $customer_id;

$this->contents = array();
$this->total = 0;
$this->weight = 0;
$this->content_type = false;

if (tep_session_is_registered('customer_id') && ($reset_database == true)) {
tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "'");
tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "'");
}

unset($this->cartID);
if (tep_session_is_registered('cartID')) tep_session_unregister('cartID');
}

function add_cart($products_id, $qty = '1', $attributes = '', $notify = true) {
global $new_products_id_in_cart, $customer_id;

$products_id = tep_get_uprid($products_id, $attributes);
if ($notify == true) {
$new_products_id_in_cart = $products_id;
tep_session_register('new_products_id_in_cart');
}

if ($this->in_cart($products_id)) {
$this->update_quantity($products_id, $qty, $attributes);
} else {
$this->contents[] = array($products_id);
$this->contents[$products_id] = array('qty' => $qty);
// insert into database
if (tep_session_is_registered('customer_id')) tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET . " (customers_id, products_id, customers_basket_quantity, customers_basket_date_added) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . $qty . "', '" . date('Ymd') . "')");

if (is_array($attributes)) {
reset($attributes);
while (list($option, $value) = each($attributes)) {
// otf 1.71 Check if input was from text box. If so, store additional attribute information
// Check if text input is blank, if so do not add to attribute lists
// Add htmlspecialchars processing. This handles quotes and other special chars in the user input.
$attr_value = NULL;
$blank_value = FALSE;
if (strstr($option, TEXT_PREFIX)) {
if (trim($value) == NULL)
{
$blank_value = TRUE;
} else {
$option = substr($option, strlen(TEXT_PREFIX));
$attr_value = htmlspecialchars(stripslashes($value), ENT_QUOTES);
$value = PRODUCTS_OPTIONS_VALUE_TEXT_ID;
$this->contents[$products_id]['attributes_values'][$option] = $attr_value;
}
}
if (!$blank_value)
{
$this->contents[$products_id]['attributes'][$option] = $value;
// insert into database
// otf 1.71 Update db insert to include attribute value_text. This is needed for text attributes.
// Add tep_db_input() processing
if (tep_session_is_registered('customer_id')) tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id, products_options_value_text) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . (int)$option . "', '" . (int)$value . "', '" . tep_db_input($attr_value) . "')");
}
}
}
}
$this->cleanup();

// assign a temporary unique ID to the order contents to prevent hack attempts during the checkout procedure
$this->cartID = $this->generate_cart_id();
}

function update_quantity($products_id, $quantity = '', $attributes = '') {
global $customer_id;

if (empty($quantity)) return true; // nothing needs to be updated if theres no quantity, so we return true..

$this->contents[$products_id] = array('qty' => $quantity);
// update database
if (tep_session_is_registered('customer_id')) tep_db_query("update " . TABLE_CUSTOMERS_BASKET . " set customers_basket_quantity = '" . $quantity . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'");

if (is_array($attributes)) {
reset($attributes);
while (list($option, $value) = each($attributes)) {
// otf 1.71 Check if input was from text box. If so, store additional attribute information
// Check if text input is blank, if so do not update attribute lists
// Add htmlspecialchars processing. This handles quotes and other special chars in the user input.
$attr_value = NULL;
$blank_value = FALSE;
if (strstr($option, TEXT_PREFIX)) {
if (trim($value) == NULL)
{
$blank_value = TRUE;
} else {
$option = substr($option, strlen(TEXT_PREFIX));
$attr_value = htmlspecialchars(stripslashes($value), ENT_QUOTES);
$value = PRODUCTS_OPTIONS_VALUE_TEXT_ID;
$this->contents[$products_id]['attributes_values'][$option] = $attr_value;
}
}

if (!$blank_value)
{
$this->contents[$products_id]['attributes'][$option] = $value;
// update database
// Update db insert to include attribute value_text. This is needed for text attributes.
// Add tep_db_input() processing
if (tep_session_is_registered('customer_id')) tep_db_query("update " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " set products_options_value_id = '" . (int)$value . "', products_options_value_text = '" . tep_db_input($attr_value) . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "' and products_options_id = '" . (int)$option . "'");
}
}
}
}

function cleanup() {
global $customer_id;

reset($this->contents);
while (list($key,) = each($this->contents)) {
if ($this->contents[$key]['qty'] < 1) {
unset($this->contents[$key]);
// remove from database
if (tep_session_is_registered('customer_id')) {
tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($key) . "'");
tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($key) . "'");
}
}
}
}

function count_contents() { // get total number of items in cart
$total_items = 0;
if (is_array($this->contents)) {
reset($this->contents);
while (list($products_id, ) = each($this->contents)) {
$total_items += $this->get_quantity($products_id);
}
}

return $total_items;
}

function get_quantity($products_id) {
if (isset($this->contents[$products_id])) {
return $this->contents[$products_id]['qty'];
} else {
return 0;
}
}

function in_cart($products_id) {
if (isset($this->contents[$products_id])) {
return true;
} else {
return false;
}
}

function remove($products_id) {
global $customer_id;
// otf 1.71 Add call tep_get_uprid to correctly format product ids containing quotes
$products_id = tep_get_uprid($products_id, $attributes);

unset($this->contents[$products_id]);
// remove from database
if (tep_session_is_registered('customer_id')) {
tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'");
tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'");
}

// assign a temporary unique ID to the order contents to prevent hack attempts during the checkout procedure
$this->cartID = $this->generate_cart_id();
}

function remove_all() {
$this->reset();
}

function get_product_id_list() {
$product_id_list = '';
if (is_array($this->contents)) {
reset($this->contents);
while (list($products_id, ) = each($this->contents)) {
$product_id_list .= ', ' . $products_id;
}
}

return substr($product_id_list, 2);
}

function calculate() {
$this->total_virtual = 0; // ICW Gift Voucher System
$this->total = 0;
$this->weight = 0;
if (!is_array($this->contents)) return 0;

reset($this->contents);
while (list($products_id, ) = each($this->contents)) {
$qty = $this->contents[$products_id]['qty'];

// products price
$product_query = tep_db_query("select products_id, products_price, products_tax_class_id, products_weight from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");
if ($product = tep_db_fetch_array($product_query)) {
// ICW ORDER TOTAL CREDIT CLASS Start Amendment
$no_count = 1;
$gv_query = tep_db_query("select products_model from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");
$gv_result = tep_db_fetch_array($gv_query);
if (ereg('^GIFT', $gv_result['products_model'])) {
$no_count = 0;
}
// ICW ORDER TOTAL CREDIT CLASS End Amendment
$prid = $product['products_id'];
$products_tax = tep_get_tax_rate($product['products_tax_class_id']);
$products_price = $product['products_price'];
$products_weight = $product['products_weight'];

$special_price = tep_get_products_special_price($prid);
if ($special_price) {
$products_price = $special_price;
}
//Impulse Item by jfj
$specials_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS_CHECKOUT . " where products_id = '" . (int)$prid . "' and status = '1'");
	  if (tep_db_num_rows ($specials_query)) {
		$specials = tep_db_fetch_array($specials_query);
		$products_price = $specials['specials_new_products_price'];
	  }
//Impulse Item by jfj		  


$this->total_virtual += tep_add_tax($products_price, $products_tax) * $qty * $no_count;// ICW CREDIT CLASS;
$this->weight_virtual += ($qty * $products_weight) * $no_count;// ICW CREDIT CLASS;
$this->total += tep_add_tax($products_price, $products_tax) * $qty;
$this->weight += ($qty * $products_weight);
}

// attributes price
if (isset($this->contents[$products_id]['attributes'])) {
reset($this->contents[$products_id]['attributes']);
while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {
$attribute_price_query = tep_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$prid . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'");
$attribute_price = tep_db_fetch_array($attribute_price_query);
if ($attribute_price['price_prefix'] == '+') {
$this->total += $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax);
} else {
$this->total -= $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax);
}
}
}
}
}

function attributes_price($products_id) {
$attributes_price = 0;

if (isset($this->contents[$products_id]['attributes'])) {
reset($this->contents[$products_id]['attributes']);
while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {
$attribute_price_query = tep_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$products_id . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'");
$attribute_price = tep_db_fetch_array($attribute_price_query);
if ($attribute_price['price_prefix'] == '+') {
$attributes_price += $attribute_price['options_values_price'];
} else {
$attributes_price -= $attribute_price['options_values_price'];
}
}
}

return $attributes_price;
}

function get_products() {
global $languages_id;

if (!is_array($this->contents)) return false;

$products_array = array();
reset($this->contents);
while (list($products_id, ) = each($this->contents)) {
// $products_query = tep_db_query("select p.products_id, pd.products_name, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_tax_class_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$products_id . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");

$products_query = tep_db_query("select p.products_id, pd.products_name, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_carrot, p.products_tax_class_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$products_id . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");

if ($products = tep_db_fetch_array($products_query)) {
$prid = $products['products_id'];
$products_price = $products['products_price'];

$special_price = tep_get_products_special_price($prid);
if ($special_price) {
$products_price = $special_price;
}
//Impulse Item by jfj
	  $specials_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS_CHECKOUT . " where products_id = '" . (int)$prid . "' and status = '1'");
	  if (tep_db_num_rows($specials_query)) {
		$specials = tep_db_fetch_array($specials_query);
		$products_price = $specials['specials_new_products_price'];
	  }
//Impulse Item by jfj


// otf 1.71 Update $products_array to include attribute value_text. This is needed for text attributes.
$products_array[] = array('id' => $products_id,
'name' => $products['products_name'],
'model' => $products['products_model'],
'image' => $products['products_image'],
'price' => $products_price,
'quantity' => $this->contents[$products_id]['qty'],
'weight' => $products['products_weight'],
'carrot' => $products['products_carrot'],
'final_price' => ($products_price + $this->attributes_price($products_id)),
'tax_class_id' => $products['products_tax_class_id'],
'attributes' => (isset($this->contents[$products_id]['attributes']) ? $this->contents[$products_id]['attributes'] : ''),
'attributes_values' => (isset($this->contents[$products_id]['attributes_values']) ? $this->contents[$products_id]['attributes_values'] : ''));
}
}

return $products_array;
}

function show_total() {
$this->calculate();

return $this->total;
}

function show_weight() {
$this->calculate();

return $this->weight;
}
// CREDIT CLASS Start Amendment
function show_total_virtual() {
$this->calculate();

return $this->total_virtual;
}

function show_weight_virtual() {
$this->calculate();

return $this->weight_virtual;
}
// CREDIT CLASS End Amendment

function generate_cart_id($length = 5) {
return tep_create_random_value($length, 'digits');
}

function get_content_type() {
$this->content_type = false;

if ( (DOWNLOAD_ENABLED == 'true') && ($this->count_contents() > 0) ) {
reset($this->contents);
while (list($products_id, ) = each($this->contents)) {
if (isset($this->contents[$products_id]['attributes'])) {
reset($this->contents[$products_id]['attributes']);
while (list(, $value) = each($this->contents[$products_id]['attributes'])) {
$virtual_check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad where pa.products_id = '" . (int)$products_id . "' and pa.options_values_id = '" . (int)$value . "' and pa.products_attributes_id = pad.products_attributes_id");
$virtual_check = tep_db_fetch_array($virtual_check_query);

if ($virtual_check['total'] > 0) {
switch ($this->content_type) {
case 'physical':
$this->content_type = 'mixed';

return $this->content_type;
break;
default:
$this->content_type = 'virtual';
break;
}
} else {
switch ($this->content_type) {
case 'virtual':
$this->content_type = 'mixed';

return $this->content_type;
break;
default:
$this->content_type = 'physical';
break;
}
}
}
// ICW ADDED CREDIT CLASS - Begin
} elseif ($this->show_weight() == 0) {
reset($this->contents);
while (list($products_id, ) = each($this->contents)) {
$virtual_check_query = tep_db_query("select products_weight from " . TABLE_PRODUCTS . " where products_id = '" . $products_id . "'");
$virtual_check = tep_db_fetch_array($virtual_check_query);
if ($virtual_check['products_weight'] == 0) {
switch ($this->content_type) {
case 'physical':
$this->content_type = 'mixed';

return $this->content_type;
break;
default:
$this->content_type = 'virtual_weight';
break;
}
} else {
switch ($this->content_type) {
case 'virtual':
$this->content_type = 'mixed';

return $this->content_type;
break;
default:
$this->content_type = 'physical';
break;
}
}
}
// ICW ADDED CREDIT CLASS - End
} else {
switch ($this->content_type) {
case 'virtual':
$this->content_type = 'mixed';

return $this->content_type;
break;
default:
$this->content_type = 'physical';
break;
}
}
}
} else {
$this->content_type = 'physical';
}

return $this->content_type;
}

function unserialize($broken) {
for(reset($broken);$kv=each($broken);) {
$key=$kv['key'];
if (gettype($this->$key)!="user function")
$this->$key=$kv['value'];
}
}
// ------------------------ ICWILSON CREDIT CLASS Gift Voucher Addittion-------------------------------Start
// amend count_contents to show nil contents for shipping
// as we don't want to quote for 'virtual' item
// GLOBAL CONSTANTS if NO_COUNT_ZERO_WEIGHT is true then we don't count any product with a weight
// which is less than or equal to MINIMUM_WEIGHT
// otherwise we just don't count gift certificates

function count_contents_virtual() { // get total number of items in cart disregard gift vouchers
$total_items = 0;
if (is_array($this->contents)) {
reset($this->contents);
while (list($products_id, ) = each($this->contents)) {
$no_count = false;
$gv_query = tep_db_query("select products_model from " . TABLE_PRODUCTS . " where products_id = '" . $products_id . "'");
$gv_result = tep_db_fetch_array($gv_query);
if (ereg('^GIFT', $gv_result['products_model'])) {
$no_count=true;
}
if (NO_COUNT_ZERO_WEIGHT == 1) {
$gv_query = tep_db_query("select products_weight from " . TABLE_PRODUCTS . " where products_id = '" . tep_get_prid($products_id) . "'");
$gv_result=tep_db_fetch_array($gv_query);
if ($gv_result['products_weight']<=MINIMUM_WEIGHT) {
$no_count=true;
}
}
if (!$no_count) $total_items += $this->get_quantity($products_id);
}
}
return $total_items;
}
// ------------------------ ICWILSON CREDIT CLASS Gift Voucher Addittion-------------------------------End
}
?>

Its the same as your code, with the two Impulse Item-additions.

 

// Fredrik

Share this post


Link to post
Share on other sites

Howdy Fredrik

 

That worked! Thanks. :lol:

 

The next important change is to have it so that the customer can click on the item and go to the product info page rather than just seeing an enlarged photo. I think that most customers are going to want to learn more about a product before they buy; furthermore, they will be back in the store where they might find yet another item, too.

 

Best Regards, Ted

 

PS. I think that it would be great to merge some of the Dangling Carrot concepts with Impulse Item

Share this post


Link to post
Share on other sites
The next important change is to have it so that the customer can click on the item and go to the product info page rather than just seeing an enlarged photo. I think that most customers are going to want to learn more about a product before they buy; furthermore, they will be back in the store where they might find yet another item, too.

My thought of this is to have a kind of product so the customer doesn?t need to make a big decision whether to buy it or not. And when I finally get the customer to check his cart and are ready to checkout I don't want to disturb him too much, if he leaves the checkout process to read more about an impulse item he might not check out at all. That's what I'm afraid of, therefore I didn't made a link to the product info-page.

 

But it could easily be adapted to do this. But then the product will also be listed in the regular catalog.

 

However, it's a quite difficult question to know what to do, to close as many sales as possible, and also sell as many products as possible on each sales. I might be wrong in this reasoning. So I hope there will be some input in this question.

 

PS. I think that it would be great to merge some of the Dangling Carrot concepts with Impulse Item

I totally agree with you B)

 

// Fredrik

Share this post


Link to post
Share on other sites
My thought of this is to have a kind of product so the customer doesn?t need to make a big decision whether to buy it or not. And when I finally get the customer to check his cart and are ready to checkout I don't want to disturb him too much, if he leaves the checkout process to read more about an impulse item he might not check out at all. That's what I'm afraid of, therefore I didn't made a link to the product info-page.

Okay, that makes sense. :thumbsup:

 

I think that there should be an option to get more info if necessary.

 

I have had some success with Dangling Carrot, so the concept is workable.

 

I really think that the Dangling Carrot concept whereby the customer feels as if she is being rewarded for buying...that's a good concept, i.e., "By spending over $19.00 you have qualified for the following Special Offer!"

 

Dangling Carrot's biggest problem is the inability to buy multiple specials.

 

I know I will get even more sales if I can get a workable Dangling/Impulse :lol:

 

Best, Ted

Share this post


Link to post
Share on other sites

Hey Ted,

 

Sorry for the late reply.

I'm glad to hear that Dangling Carrot is generating sales for you.

 

I don't have anythng to report on the Impulse Item at this momet, since we don't have it installed yet on our live shop.

 

// Fredrik

Share this post


Link to post
Share on other sites

Howdy Fredrik

 

Any new news to report?

 

I am very surprised that more are not interested in this contribution. It is a great idea.

 

Best, Ted

Share this post


Link to post
Share on other sites
Howdy Fredrik

 

Any new news to report?

 

I am very surprised that more are not interested in this contribution. It is a great idea.

 

Best, Ted

Sorry Ted, nothing to report yet. I'm planning to redesign our shop completly in a (hopefully) near future. And then I might have someting to report from our side.

 

If someone else use this contrib or Dangling Carrot, feel free to tell us if it has generated any extra sales

 

// Fredrik

Share this post


Link to post
Share on other sites

Hi,

 

Do you mean special_checout.php in your instruction 10? I can't find specials.php in the files I downloaded from your contribution.

 

 

============================================

10. Uploade the files

============================================

 

catalog/specials.php

catalog/admin/specials.php

catalog/admin/includes/languages/specials_checkout.php

Share this post


Link to post
Share on other sites
Hi,

 

Do you mean special_checout.php in your instruction 10? I can't find specials.php in the files I downloaded from your contribution.

 

 

============================================

10. Uploade the files

============================================

 

catalog/specials.php

catalog/admin/specials.php

catalog/admin/includes/languages/specials_checkout.php

 

It was quite some time I did this. But I guess I made a typo in the readme file. Upload the included files into the proper folders in your shop.

So the correct readme should say;

============================================

10. Uploade the files

============================================

catalog/specials_checkout.php

catalog/admin/specials_checkout.php

catalog/admin/includes/languages/specials_checkout.php

 

 

//Fredrik

Share this post


Link to post
Share on other sites
Hi,

 

I don't have Gift Item in my admin>catalog.

If you inserted all the modifications for the admin side and uploaded all 3 php-files it should be located at www.YourURL.com/catalog/admin/specials_checkout.php

 

//Fredrik

Share this post


Link to post
Share on other sites

Hi Fredrik,

 

Thanks for the reply.

 

Where can I find the define for "MAX_DISPLAY_SPECIAL_PRODUCTS"? You had used it in your specials_checkout.php?

The programs work for me beautifully. I just need to change this define.

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  

×