custom product doesn't display in minicart / cart

  • Posts: 164
  • Thank you received: 6
  • Hikashop Business
4 years 9 months ago #319664

-- HikaShop version -- : 4.3.0
-- Joomla version -- : 3.9.18
-- PHP version -- : 7.3.187

Good evening,

Since the last update of Hikashop 15 minutes ago the products (generated by our customer in a configurator) thumbnail doesn't display in the cart or the minicart. So far it did, until this new version.

We developed a helper file for our custom module that you will find below. with a few url parameters hidden...

Maybe having a look at it you could find instantly what would be the modification to make in the code given this new release of Hikashop?

Something similar happened already for the add of the product itself in the cart after the last release! It was just a letter to change in a function....

I would be really thankful since I'm basically not an IT guy (at least for this kind of issue)...

Jean-Loup Ribordy

defined('_JEXEC') or die;

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

abstract class modConfiguratorHelper
{
    public static function getItems(&$params)
    {		
	$jInput = JFactory::getApplication()->input;

	$watchPrice = $jInput->get( 'watchprice' );
        $watchId    = $jInput->get( 'watchid' );
        $watchName  = $jInput->get( 'watchname' );
        $watchHash  = $jInput->get( 'watchhash' );
	$hashkey    = $watchId . $watchPrice . '1.21!stbcssblck';
		
	$productClass = hikashop_get('class.product');
	$product = new stdClass();
	$product->product_name = $watchName;
	$product->product_code = $watchId;
	$product->product_msrp = $watchPrice;
	$product->product_published = 1;
	$product->product_quantity = 3;
        $product->product_tax_id = 11;
	$product->product_warehouse_id = 1;
	$product->categories = array(47);
		
	$price = null;
	$price->price_value = $watchPrice;
	$price->price_currency_id = 151; //151:chf 1:euro 2:usd
	$price->price_min_quantity = 1;
        $price->price_with_tax = $watchPrice;
	$product->prices = array($price);
		
	$result = $productClass->fullSave($product);
	$productClass->updatePrices($product, $result);
	$productClass->updateCategories($product, $result);
	  
	  //$categoryClass = hikashop_get('class.category');
	  //$category_product = new stdClass();
	  //$category_product->category_id = 47;
	  //$category_product->product_id = $productClass->product_id;
	  //$category_product->product_id = 2867;
	  //$result1 = $categoryClass->save($category_product);
	  
	  //$db =& JFactory::getDBO();
	  //$db->setQuery('INSERT INTO '.hikashop::table('product_category').' (product_id, category_id) VALUES ('.$productClass->product_id) .','47')';
	  //$current_result = $db->loadResult();
		
	$cartClass = hikashop_get('class.cart');
	$cartClass->update($result,1);
		
	$urlwatch = 'https://xxxxxxxxxx/121time/orders/'. $watchId .".png";
	$imgwatch = '/home/clients/xxxx/web/images/com_hikashop/upload/customwatchhtml/'. $watchId .".png";
		
	$ch = curl_init($urlwatch);
	$fp = fopen($imgwatch, 'wb');
	curl_setopt($ch, CURLOPT_FILE, $fp);
	curl_setopt($ch, CURLOPT_HEADER, 0);
	curl_exec($ch);
	curl_close($ch);
	fclose($fp);
		
	$imageURL 		= 'customwatchhtml/'. $watchId .".png";
	$msg        = '';
	    
	//traitement image
	$image = new stdClass();
	$image->file_ref_id = $result;
	$image->file_type = 'product';
	$image->file_path = $imageURL;
	$fileClass = hikashop_get('class.file');
	$id = $fileClass->save($image);
	$product->images = array($id);
	$productClass->updateFiles($product,$result,'images');
        
        $link = '/cart/checkout';

	$app = JFactory::getApplication();
	$app->redirect($link, $msg);
        
        return "->price:". $watchPrice ."-id:". $watchId ."-name:". $watchName;
    }
}

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

  • Posts: 83409
  • Thank you received: 13502
  • MODERATOR
4 years 9 months ago #319679

Hi,

You're talking about this:
www.hikashop.com/forum/checkout/899318-a...o-basket.html#316425
We actually changed back to the save function as it caused problems with other extensions integrating with HikaShop and made other fixes in a different way.
So you just have to change back from fullSave to save in your code and it should work again.

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

  • Posts: 164
  • Thank you received: 6
  • Hikashop Business
4 years 9 months ago #319689

Good morning

Thank you for your quick answer.

Sorry to say that but to come back to the "save" function doesn't work; it is even worse in the sense that it is not anymore possible at all to add any custom product in the cart.

With the fullSave, only the thumbnail wasn't working but the product could be added. Now even the product can't be added.

BTW I tired also to clear all cache, JCH optimize and JotCache

Any idea?

Wish you a good day

Jean-Loup

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

  • Posts: 164
  • Thank you received: 6
  • Hikashop Business
4 years 9 months ago #319703

BTW I put back the fullSave in order to be able at least to add a product, even without image!

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

  • Posts: 83409
  • Thank you received: 13502
  • MODERATOR
4 years 9 months ago #319694

Hi

Wait, the rollback to save is for the next release. We didn't yet change that.
So yes, you want to keep using the fullSave function for now.
Now, I don't know why the thumbnail wouldn't display. I don't see anything we changed in the 4.3.0 which could lead to that.
If you check the product in the backend, do you see the image ? Is the URL correct ?
I would start there.

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

  • Posts: 164
  • Thank you received: 6
  • Hikashop Business
4 years 9 months ago #320144

Hello Nicolas,
I just noticed that on our configurator server, the image is created, but is transfered on image/upload from Hikashop without any size, just the name is here. Any idea what it could be? Rights seems to be ok on Hika folders. Anyway I didn't touched anything

It stopped on May... was it after an Hika update? I don't remember...

Thank you for your help

JL

Attachments:

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

  • Posts: 164
  • Thank you received: 6
  • Hikashop Business
4 years 9 months ago #320149

and BTW it is possible that I jumped from a 4.1 version directly to 4.3

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

  • Posts: 83409
  • Thank you received: 13502
  • MODERATOR
4 years 9 months ago #320146

Hi,

Ok, I think I see what's the problem.
It's not a problem with the save or the update of HikaShop.
In your code, you have some lines to load the image from somewhere :

$urlwatch = 'https://xxxxxxxxxx/121time/orders/'. $watchId .".png";
	$imgwatch = '/home/clients/xxxx/web/images/com_hikashop/upload/customwatchhtml/'. $watchId .".png";
		
	$ch = curl_init($urlwatch);
	$fp = fopen($imgwatch, 'wb');
	curl_setopt($ch, CURLOPT_FILE, $fp);
	curl_setopt($ch, CURLOPT_HEADER, 0);
	curl_exec($ch);
	curl_close($ch);
	fclose($fp);
And you fopen the destination file but you fclose it without writing anything in it.
I think that you're missing a line of code to get the result of the curl_exec and write it to $fp.
You must have removed it inadvertently when you were figuring out the issue with the save/fullSave function name.
That would explain with the file is there but empty.

And yes, you can jump versions, that's not a problem. We've had people going from a HikaShop 2.x to a HikaShop 4.3.0 directly so 4.1 to 4.3 is no problem :)

Last edit: 4 years 9 months ago by nicolas.
The following user(s) said Thank You: jean-loup

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

Time to create page: 0.082 seconds
Powered by Kunena Forum