Can't get products array from fullOrder

  • Posts: 7
  • Thank you received: 0
11 years 3 months ago #117294

Hi guys,

Would you mind having a look at this for me?

I'm loading the full order, so that I can access shipping address, product etc. But I can't seem to get the products array.

What I intend to do is add more code which will create an invoice and customer in Kashflow, hence the //create variables

<?php

defined('_JEXEC') or die('Restricted access');

?><?php

if(!@include_once(rtrim(JPATH_ADMINISTRATOR,DS).DS.'components'.DS.'com_hikashop'.DS.'helpers'.DS.'helper.php')){ return false; }

class plgHikashopkf_insert extends JPlugin

{

	function plgHikashopKashflow(&$subject, $config){

		parent::__construct($subject, $config);
		if(!isset($this->params)){
			$plugin =& JPluginHelper::getPlugin('hikashop', 'kf_insert');
			jimport('joomla.html.parameter');
			$this->params = new JParameter( $plugin->params );
		}

	}


	function onAfterOrderCreate(&$order,&$send_email){
		

    	if(!empty($order->order_id)){
 					
		$orderClass = hikashop_get('class.order');
		$full_order = $orderClass->loadFullOrder($order->order_id, true, false);

		//create variables
		$email = $send_email;
		$cart = $full_order->products->order_product_name;
		$inv_name = $full_order->shipping_address->address_firstname . " " .     $full_order->shipping_address->address_lastname; 
		$inv_addr1 = $full_order->shipping_address->address_street;
		$inv_addr2 = $full_order->shipping_address->address_city;
		$inv_state = $full_order->shipping_address->address_state;
		$inv_zip = $full_order->shipping_address->address_post_code;
		$inv_country = $full_order->shipping_address->address_country;
		$description = $cart;
		$qty = '1';
		$subtotal = $full_order->products->order_product_price;
		$tax_rate = 20;
		$tel = $full_order->shipping_address->address_telephone;
		$shipping = $full_order->shipping->shipping_price;
		
		//email
		$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
		$from = "no_replies_please@*********.co.uk";
		$headers .= "From:".$from;
		$email_add = '**@****.net';		
		$subject = 'Test';
		$message = $full_order->products->order_product_name;
			
        mail($email_add, $subject, $message, $headers);
    	}
		return true;
    }
	
}

?>

I've also tried to access the product information like this:
$productClass = hikashop_get('class.product');
  		$full_product = $productClass->getProducts( $this->element->product_id );

and then:
$message = $full_product->product_name;

But the message is blank.

Probably something silly, apologies if so :unsure:

Many thanks
Eleventy

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
11 years 3 months ago #117296

$full_order->products is an array of products.
So you can't do:
$cart = $full_order->products->order_product_name;

You should do:
foreach($full_order->products as $product){
$cart = $product->order_product_name;
}

The following user(s) said Thank You: eleventy

Please Log in or Create an account to join the conversation.

  • Posts: 7
  • Thank you received: 0
11 years 3 months ago #117301

Hi Nicolas, thanks very much :)

Please Log in or Create an account to join the conversation.

Time to create page: 0.057 seconds
Powered by Kunena Forum