AbanteCart Development > API Development
Get cust data in lib/cart.php
yonghan79:
Hi core devs,
I wonder if we can get/set the cust_data within the lib/cart.php via hook?
I want to add some info in add and buildProductDetails from admin side.
Thanks.
abolabo:
you should to find new instance defining of ACart class and recreate it with your additional data.
See https://github.com/abantecart/abantecart-src/blob/master/public_html/extensions/fast_checkout/storefront/controller/pages/checkout/fast_checkout.php#L53 as example.
Also do not forget you can replace ACart object inside Registry with your's own class that extends base ACart class inside init hook (for overriding some methods).
see https://github.com/abantecart/abantecart-src/blob/master/public_html/core/init.php#L524
Example:
public function onAHook_InitEnd(){
$registry = Registry::getInstance();
$session = $registry->get('session');
$session['cart']['some_custom_data'] = $some_data;
$registry->set('cart', new CustomACartClass($registry, $session));
}
yonghan79:
Thanks abolabo, i will learn about them first. I will ask again if i don't understand.
I wonder if it's possible to change the protected cust_data become public cust_data in the cart.php?
abolabo:
--- Quote from: yonghan79 on April 30, 2021, 05:34:28 AM ---Thanks abolabo, i will learn about them first. I will ask again if i don't understand.
I wonder if it's possible to change the protected cust_data become public cust_data in the cart.php?
--- End quote ---
see this https://github.com/abantecart/abantecart-src/blob/master/public_html/core/lib/cart.php#L88
cust_data becomes from constructor parameters. That's why i propose to reinitialize cart object inside registry.
yonghan79:
Got it, i will do some more testing.
Another question. I see there is
--- Code: ---$this->registry->get('extensions')->hk_ProcessData($this, __FUNCTION__, ['total_text_id' => $extn]);
--- End code ---
within the cart.php too.
How do i use it?
Navigation
[0] Message Index
[#] Next page
Go to full version