Jump to content

Email loop results in function


blogit

Recommended Posts

Hello, i'm working with a shopping cart script that saves user carts to their profile, however it deletes them if they remove items. I'd like to get an email each time they add an item or the function below is ran so i can try and save abandoned carts by emailing the users. The script has no option to save them in the admin back end. I've tried adding a simple mail function with some variables but have only been able to get the userid and some other data to be sent. While messing around with another function in the cart which add's the product to the cart i tried the same basic mail function and the variable i was adding to the email came up as 'Array' in the emails i received. If anyone can show me how to capture the looped information into a variable that i can email my self i would really appreciate it

 

Thanks in advance

 

//
// Store cart content in the customer's profile
//
function fn_save_cart_content(&$cart, $user_id, $type = 'C' , $user_type = 'R')
{
global $db_tables;

if (empty($user_id)) {
	if (fn_get_cookie('cu_id')) {
		$user_id = fn_get_cookie('cu_id');
	} else {
		$user_id = abs(crc32(uniqid(TIME)));
		fn_set_cookie('cu_id' , $user_id , COOKIE_ALIVE_TIME);
	}
	$user_type = 'U';
}

if (!empty($user_id)) {
	db_query("DELETE FROM $db_tables[user_session_products] WHERE user_id='$user_id' AND type='$type' AND user_type = '$user_type'");
	if (!empty($cart['products']) && is_array($cart['products'])) {
		$_cart_prods = $cart['products'];
		foreach ($_cart_prods as $_item_id => $_prod) {
			$_cart_prods[$_item_id]['user_id'] = $user_id;
			$_cart_prods[$_item_id]['timestamp'] = TIME;
			$_cart_prods[$_item_id]['type'] = $type;
			$_cart_prods[$_item_id]['user_type'] = $user_type;
			$_cart_prods[$_item_id]['item_id'] = $_item_id;
			$_cart_prods[$_item_id]['item_type'] = 'P';
			$_cart_prods[$_item_id]['extra'] = addslashes(serialize($_prod));
			$_cart_prods[$_item_id]['amount'] = empty($_cart_prods[$_item_id]['amount']) ? 1 : $_cart_prods[$_item_id]['amount'];
			$_cart_prods[$_item_id] = fn_check_table_fields($_cart_prods[$_item_id], $db_tables['user_session_products']);
			if (!empty($_cart_prods[$_item_id])) {
				db_insert_by_array($db_tables['user_session_products'], $_cart_prods[$_item_id], true);
			}
		}
	}

	$function = __FUNCTION__;
	include CORE_DIR . 'addons_inheritance.php';

}
return true;
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.