cart ID

  • Posts: 69
  • Thank you received: 1
10 years 1 month ago #195570

-- HikaShop version -- : 3.2.5
-- Joomla version -- : 3.3.6
-- PHP version -- : 5.3.29

Hi,

I amusing Hiakshop as a B2B catelogue. My customers do not want to log in, but do desire to ask me questions about items in their cart. The also want to show their cart to others.

So, for an anonymous persistent cart:

1. Is there a way to display the cart ID? Could I do this in checkout/cart.php or would I have to write a plugin?

2. If the cart ID is available, is there a way for me to display a cart (on the front end) using the cart ID? How best could this be done (component, plugin, altering the cart view? If the cart cannot be displayed on the front end, what other alternatives might I investigate. I could mail the cart to someone. Are there other alternatives to share a guest/anonymous cart?

Thanks,

Dennis


______________
Dennis Kmetz

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

  • Posts: 13201
  • Thank you received: 2322
10 years 1 month ago #195577

Hi,

You could potentially use the wishlist function.
This allow to have kind of cart and share them with anybody, or only users having the link.

The only condition is to be logged in to create a wishlist, then the other users cab be logged in or not.

Last edit: 10 years 1 month ago by Xavier.

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

  • Posts: 69
  • Thank you received: 1
10 years 1 month ago #195699

Xavier,

Sorry, as noted above, login is not an option for me. My customers do not want to log in. Can you address my two questions please.

Dennis


______________
Dennis Kmetz

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

  • Posts: 83674
  • Thank you received: 13545
  • MODERATOR
10 years 1 month ago #195702

Hi,

1.You can use such code in the checkout/cart view file in order to display the cart id:
<?php echo $this->full_cart->cart_id; ?>

2. If you want to display the current cart somewhere there are two steps:
1. You load the cart data. It can be done easily with such code:
$cartClass = hikashop_get('class.cart');
$cartData = $cartClass->loadFullCart(true);

2.Then, you need to use the data in $cartData in order to display the cart. That's the hard part. It would take a few hundred lines, somewhat similar to what you have in checkout/cart but a bit different. So it would require a developer to do that.

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

  • Posts: 69
  • Thank you received: 1
10 years 1 month ago #195773

Hi Nicolas,

Item 1 solved... thank you... it works just fine.

For item 2, I am looking for a way to display the cart (the products within a cart) given a cart_id, not using the cart_id from the current session... that is, not from the current cart but rather based entirely on a cart_id. How best could this be done (component, plugin, altering the product/cart view?)

If given a cart_id, a cart cannot be displayed on the front end, what other alternatives might I investigate that would allow me to show the contents of a cart to someone who is not logged in and not the owner of the cart? I guess I could email the contents of the cart to them.... that would be one way to show it to someone. But I am more interested in knowing if there any Hikashop alternatives?

Thanks so much,

Dennis


______________
Dennis Kmetz

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

  • Posts: 26226
  • Thank you received: 4035
  • MODERATOR
10 years 1 month ago #195787

Hi,

You can use the function "loadCart" instead of the function "loadFullCart".
The "loadCart" function have as first parameter the id of the cart you want to load. If you give him "0", it will load the current cart (in the session).

After that, if you're using the multi-cart option in HikaShop, the user will be able to have multiple cart and see them in the HikaShop user control panel.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

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

  • Posts: 69
  • Thank you received: 1
10 years 1 month ago #195831

Jerome,

Thanks for the prompt reply... especially on a weekend.

For me, the loadCart function does not return the list of products within the cart... here is what I get:

object(stdClass)#1292 (10) {
  ["cart_id"]=>   string(2) "79"
  ["user_id"]=>   string(1) "0"
  ["session_id"]=>   string(32) "fc3d2524b62ec8c676771f4cfea2aefc"
  ["cart_modified"]=>   string(10) "1426959722"
  ["cart_coupon"]=>   string(0) ""
  ["cart_type"]=>   string(4) "cart"
  ["cart_current"]=>   string(1) "0"
  ["cart_share"]=>   string(6) "nobody"
  ["cart_name"]=>   string(0) ""
  ["cart_params"]=>   string(0) ""
}

The loadFullCart function returns the list of products for the current user/session.

Are you saying that I should use these two functions together? Perhaps I do not understand... but what I am looking for is a way to display the the products within a cart given a cart_id, not using the cart_id from the current session.

Thanks again,

Dennis


______________
Dennis Kmetz

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

  • Posts: 83674
  • Thank you received: 13545
  • MODERATOR
10 years 1 month ago #195845

Hi,

For the list of products, it's the get function you can use like this:
$cartClass = hikashop_get('class.cart');
$products= $cartClass->get($cart_id);

The following user(s) said Thank You: dkmetz@taylorbruce.com

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

  • Posts: 69
  • Thank you received: 1
10 years 2 weeks ago #198621

Nicolas,
This helped me quite a bit... thank you. I can now save a cart and pass it to others to view. I had to also use the product class to get information on the products within the cart. Here is what I ended up with:

// display a cart given a cart ID 
	$cart_id = JRequest::getInt('id',''); 				// 0 or a cart ID
	$cartClass = hikashop_get('class.cart');
	$productClass = hikashop_get('class.product');
	$cartData = $cartClass->get($cart_id); 			// if 0 then the current (the cart of the owner) cart is returned...  
	foreach($cartData as $row): 
		$showCartID = array((int)$row->cart_id); 	// regardless, get the ID of the cart we are working with
		$showCartID = $showCartID[0];
	endforeach;

Then to display the products in the cart:
	// BEGIN DISPLAY CART ROW 
	foreach($cartData as $row): 
	?>
	<div class="row-fluid cart-item row<?php echo ($row->product_id); ?> ">
		<?php
		$productData = $productClass->get($row->product_id); 
		$productsInCart = array((int)$row->product_id);
		$productClass->getProducts($productsInCart);
		// PRODUCT CODE AND NAME START *************************
		?>
		<div class="span4 hikashop_cart_product_name_value">
			<?php	
			$productData = $productClass->get($row->product_id);
			$productClass = hikashop_get('class.product');
			echo("<h4>" . $productData->product_code."</h4>");
			echo("<span>" . $productData->product_name."</span>");
			?>
		</div><!-- span4 hikashop_cart_product_name_value  -->
		<?php
		// PRODUCT CODE AND NAME END   *************************
	</div><!-- row-fluid cart-item row -->		
<?php		
	endforeach;	
	// END DISPLAY CART ROW 
?>
</div><!-- hikashop_checkout_cart_display -->


______________
Dennis Kmetz
The following user(s) said Thank You: nicolas

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

  • Posts: 69
  • Thank you received: 1
10 years 1 week ago #198926

Hi,

Well, all is working quite well... I am sending my cart ID to others and they can see my cart just fine using the above code (thank you) inserted into the cart.php view..

Then I send my cart to my customer... and it does not work.

What I discovered is that the cart controller will not execute my (moified) cart view unless there is a "local" cart... so what this means for me is that I cannot show my cart to someone who does not have a cart of their own. So I cannot share my cart with someone unless they have their own cart... they cannot use my modified cart.php view to see my cart unless they have their own cart.

Is there any way to fix this? Is there any way (aside from modifying the controller code) to have my cart.php view executed for a person who has no cart of their own?

Dennis


______________
Dennis Kmetz

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

  • Posts: 26226
  • Thank you received: 4035
  • MODERATOR
10 years 1 week ago #199031

Hi,

The cart controller ?
Are you sure that you're not talking about the checkout controller ?

Because I don't see any code in the cart controller which check that the user have a cart ; but I know that the checkout controller perform that check.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

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

  • Posts: 69
  • Thank you received: 1
10 years 1 week ago #199042

Hi Jerome,

Yes... the checkout controller. (my mistake).

Dennis


______________
Dennis Kmetz

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

  • Posts: 83674
  • Thank you received: 13545
  • MODERATOR
10 years 1 week ago #199114

Hi,

There is no system to bypass the cart check in the checkout controller.
So you have two choices:
- You use a Joomla system plugin class override and override the whole checkout controller and redefine the step function in it.
- You directly modify the step function in the controller.

I would recommend the second option. It's a hack, but compared to an override of the whole checkout controller, it's a close call as you'll probably get many issues with the updates with such overrides as the checkout controller changes a lot for each release. And modifying directly the checkout controller is much easier and can easily be done again after each update.

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

  • Posts: 69
  • Thank you received: 1
10 years 1 week ago #199116

Regarding the step function... can you give me some guidance as to how and where to start.


______________
Dennis Kmetz
Last edit: 10 years 1 week ago by dkmetz@taylorbruce.com. Reason: info

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

  • Posts: 83674
  • Thank you received: 13545
  • MODERATOR
10 years 1 week ago #199117

Removing the check on the cart on the checkout controller is easy.
Just remove that code in the checkout controller file:

if(empty($class->cart->cart_id)){
			$this->setRedirect( $this->redirect_url, JText::_('CART_EMPTY'));
			return true;
		}

The following user(s) said Thank You: dkmetz@taylorbruce.com

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

  • Posts: 69
  • Thank you received: 1
10 years 6 days ago #199625

Nicolas,

Thanks for your help... the above works for me.
I hope that you will consider making this an option in a future release. For a B2B application like mine it helps to easily allow my colleagues to see my cart (at their computer).

Thanks again,

Dennis


______________
Dennis Kmetz

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

Time to create page: 0.098 seconds
Powered by Kunena Forum