Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

How To Attach Extra Information To Order Item Rate Topic   - - - - -

 
  • Elsherif
  • Member
  • Trial users
  • Join Date: 10-Jul 15
  • 36 posts

Posted 28 July 2015 - 12:05 PM #1

Hello everyone,

I want to know how can I attach additional information to product order from an addon.
I tried using 'pre_add_to_cart', 'add_to_cart, and 'post_add_to_cart' hooks.
But whenever I add any information to the product or the cart array it gets deleted in the next step so how can I do this?

 

Posted 28 July 2015 - 06:12 PM #2

hi Elsherif,

you used correct hooks, but there is a trick:
if you print $_SESSION['cart'] array, product info is stored in $_SESSION['cart']['products'] and every cart product has unique hash - $_SESSION['cart']['products'][$cart_id] where $cart_id is the hash

every cart product has extra key (type - array) - $_SESSION['cart']['products'][$cart_id]['extra'], for example in extra product option info is stored and if you add subkey to extra it will be automatically saved into order details


the main idea of this feature is that when you add product to cart, you should add necessary info as subkey into extra

hope it helps.

best regards,
WSA team

 
  • Elsherif
  • Member
  • Trial users
  • Join Date: 10-Jul 15
  • 36 posts

Posted 29 July 2015 - 05:12 AM #3

hi Elsherif,

you used correct hooks, but there is a trick:
if you print $_SESSION['cart'] array, product info is stored in $_SESSION['cart']['products'] and every cart product has unique hash - $_SESSION['cart']['products'][$cart_id] where $cart_id is the hash

every cart product has extra key (type - array) - $_SESSION['cart']['products'][$cart_id]['extra'], for example in extra product option info is stored and if you add subkey to extra it will be automatically saved into order details


the main idea of this feature is that when you add product to cart, you should add necessary info as subkey into extra

hope it helps.

best regards,
WSA team

Thanks a lot ... I've tried adding to the extra field but not in the $_SESSION array, instead I was adding to the hook's $cart array so, I think that was the trick. It is working fine now. :)

 
  • Elsherif
  • Member
  • Trial users
  • Join Date: 10-Jul 15
  • 36 posts

Posted 29 July 2015 - 06:34 AM #4

Now I can attach data to the order item successfully while it is in the cart but how to retrieve it after checkout and placing the order?

 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 21914 posts

Posted 29 July 2015 - 08:42 AM #5

Please try

{foreach from=$order_info.products item="product" key="key"}
    {$product.extra|fn_print_r}
{/foreach}

GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    Multi-Vendor PLUS           USD 3100 (2775)
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      Multi-Vendor Ultimate       USD 7500 (6000)

 
  • Elsherif
  • Member
  • Trial users
  • Join Date: 10-Jul 15
  • 36 posts

Posted 29 July 2015 - 01:23 PM #6

Please try

{foreach from=$order_info.products item="product" key="key"}
	{$product.extra|fn_print_r}
{/foreach}

Thank you ... it is working fine now :)