Jump to content

Trouble with options box


dcuellar

Recommended Posts

Hello!

 

I'm having problems getting this options box to work.

 

http://www.unifiedchamp.com/ucforum/cartplog.php?do=viewitem&cartplogproductid=22

 

The first option box to the left was what came originally with the program. The second was what I have added.

 

Here is the php code:

if ($_REQUEST['do'] == 'viewitem')
{
$vbulletin->input->clean_array_gpc('r', array(
	'cartplogproductid' => TYPE_UINT,
));
$cartplog['productid'] = $vbulletin->GPC['cartplogproductid'];

$cartplog_product_check = $db->query_first("SELECT *
	FROM " . TABLE_PREFIX . "cartplog_products
	WHERE productid = " . intval($cartplog['productid']) . "
");

if ($cartplog_product_check)
{
	$cartplog['product_productid'] = intval($cartplog_product_check['productid']);
	$cartplog['product_thumb'] = strval($cartplog_product_check['thumb']);
	$cartplog['product_title'] = htmlspecialchars_uni($cartplog_product_check['title']);
	$cartplog['product_description'] = strval($cartplog_product_check['description']);
	$cartplog['product_price'] = round(floatval($cartplog_product_check['price']), 2);
	$cartplog['product_options'] = '';
	$cartplog['product_options2'] = '';
                //Fix productprice
        $cartplog['product_price'] = '$' . number_format($cartplog['product_price'], 2);

	$cartplog_product_options = array_map('trim', unserialize($cartplog_product_check['options']));
	$cartplog_product_options2 = array_map('trim', unserialize($cartplog_product_check['options2']));
	if (!is_array($cartplog_product_options))
	{
		$cartplog_product_options = array();
	}
	if (!is_array($cartplog_product_options2))
	{
		$cartplog_product_options2 = array();
	}
	foreach($cartplog_product_options AS $cartplog_options_key => $cartplog_options_title)
	{
		if (vbstrlen($cartplog_options_title))
		{
			$cartplog['options_title'] = htmlspecialchars_uni($cartplog_options_title);
			$cartplog['product_options'] .= '<option value="' . $cartplog['options_title'] . '">' . $cartplog['options_title'] . '</option>';
			$cartplog['product_options'] .= "\n";
		}
	}
	foreach($cartplog_product_options2 AS $cartplog_options_key => $cartplog_options_title)
	{
		if (vbstrlen($cartplog_options_title))
		{
			$cartplog['options_title'] = htmlspecialchars_uni($cartplog_options_title);
			$cartplog['product_options2'] .= '<option value="' . $cartplog['options_title'] . '">' . $cartplog['options_title'] . '</option>';
			$cartplog['product_options2'] .= "\n";
		}
	}


	if ($cartplog['product_options'])
	{
		$cartplog['product_options'] = '<select name="cartplogoptions">' . $cartplog['product_options'] . '</select>';
	}
	if ($cartplog['product_options2'])
	{
		$cartplog['product_options2'] = '<select name="cartplogoptions2">' . $cartplog['product_options2'] . '</select>';
	}

	$navbits = array();
	$navbits['cartplog.php' . $vbulletin->session->vars['sessionurl_q']] = htmlspecialchars_uni($vbphrase['cartplog']);
	$navbits[''] = htmlspecialchars_uni($vbphrase['cartplog_view_item']);
	$navbits = construct_navbits($navbits);

	eval('$navbar = "' . fetch_template('navbar') . '";');
	eval('print_output("' . fetch_template('cartplog_view_item') . '");');
}
else
{
	$cartplog_url = 'cartplog.php?' . $vbulletin->session->vars['sessionurl'] . 'do=viewindex';
	exec_header_redirect($cartplog_url);
	exit();
}
}

Anywhere you see the number 2 following the word options is what I have added. Some of this may not even need to be in there as I am just using trial and error.

 

Let me know what you think I can do. The drop down box to the right should reflect options for color. These colors have already been inputted through my admincp.

 

Let me know if you need to take a look at the full php script.

Link to comment
https://forums.phpfreaks.com/topic/91329-trouble-with-options-box/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.