Jump to content

Product Appearances - Brian


Claudia
 Share

Recommended Posts

Product Appearances

Hi Brian,

First off thank you for this - it is wonderful!  I've tweaked it a little to add columns that I use. I don't know if that has anything to do with the error I keep getting but I wanted you to be aware of it.  Also I didn't add any of my custom columns below because I really don't use the language/ definitions file much.  I have it hard coded in the product order index file.

 

if ($existing_orders) {

                                    $product_orders_thead = array(

                                      'cart_order_id'   => $lang['orders']['order_number'],

                                      'cart_oid'   => $lang['common']['order_id'],

                                      'cart_customer' => $lang['orders']['customer_name'],

                                      'gateway_name' => $lang['orders']['gateway_name'],

                                      'shipping_date' => $lang['orders']['shipping_date'],

                                      'shipping_method' => $lang['orders']['shipping_method'],

                                    );

Error:

[20-Nov-2022 21:27:45 America/Louisville] PHP Warning:  count(): Parameter must be an array or an object that implements Countable in /home/xxxxxxx/public_html/modules/plugins/Product_Appearances/hooks/admin.product.tabs.php on line 22

 

Line 22:

$GLOBALS['main']->addTabControl($lang['orders']['title_orders'], 'orders',null,null,count($existing_orders),'_self',10);

 

Also even if there are no orders for a product 1 in a red circle on the product / orders tab

 

I'm not complaining, very thankful for this, just thought you might like to know

Claudia

PA Order Info.PNG

PA Orders red.PNG

Link to comment
Share on other sites

Thank you for this. PHP 8 does not like counting nothing.

Replace the hook admin.product.tabs.php with the following content:

<?php
	if (!defined('CC_INI_SET')) {
		die('Access Denied');
	}
	if($result[0]['product_id'] > 0){
		$existing_orders = $GLOBALS['db']->select('`'.$GLOBALS['config']->get('config', 'dbprefix').'CubeCart_order_inventory` LEFT JOIN `'.$GLOBALS['config']->get('config', 'dbprefix').'CubeCart_order_summary` USING (`cart_order_id`)', '`'.$GLOBALS['config']->get('config', 'dbprefix').'CubeCart_order_summary`.*', array('product_id' => (int)$result[0]['product_id']),'order_date DESC');
			$product_orders_thead = array(
			  'cart_order_id'   => $lang['orders']['order_number'],
			  'cart_oid'   => $lang['common']['order_id'],
			  'cart_customer' => $lang['orders']['customer_name'],
			  'gateway_name' => $lang['orders']['gateway_name'],
			  'shipping_date' => $lang['orders']['shipping_date'],
			  'shipping_method' => $lang['orders']['shipping_method'],
			);
		$GLOBALS['smarty']->assign('PRODUCT_ORDERS_TAB_CONTENT_THEAD',$product_orders_thead);
		if ($existing_orders === false) { $existing_orders = array(); }
		$GLOBALS['smarty']->assign('PRODUCT_ORDERS',$existing_orders);
		$GLOBALS['hook_tab_content'][] = CC_ROOT_DIR.CC_DS.'modules'.CC_DS.'plugins'.CC_DS.'Product_Appearances'.CC_DS.'skin'.CC_DS.'edit_product'.CC_DS.'product.tpl';
		$GLOBALS['main']->addTabControl($lang['orders']['title_orders'], 'orders',null,null,count($existing_orders),'_self',10);

	}

This should work better under PHP 8.

Link to comment
Share on other sites

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.   Paste as plain text instead

  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.

 Share

×
×
  • Create New...