AbanteCart Development > API Development
Get cust data in lib/cart.php
abolabo:
--- Quote from: yonghan79 on April 30, 2021, 05:49:48 AM ---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?
--- End quote ---
no way. processData is a controller's call.
You should to override ACart with your class and override base methods
YourCart extends ACart ....
yonghan79:
--- Code: ---foreach ($total_extns as $extn) {
$sf_total_mdl = $this->load->model('total/'.$extn['key'], 'storefront');
/**
* parameters are references!!
*
* @var ModelTotalTotal $sf_total_mdl
*/
$sf_total_mdl->getTotal($total_data, $total, $taxes, $this->cust_data);
//trick to change data via hooks
$this->data = [
'total_key' => $extn['key'],
'total_data' => $total_data,
'total' => $total,
'taxes' => $taxes,
];
$this->registry->get('extensions')->hk_ProcessData($this, __FUNCTION__, ['total_text_id' => $extn]);
$total_data = $this->data['total_data'];
$total = $this->data['total'];
$taxes = $this->data['taxes'];
unset(
$this->data['total_key'],
$this->data['total_data'],
$this->data['total'],
$this->data['taxes']
);
$sf_total_mdl = null;
}
--- End code ---
I see there is //trick to change data via hooks.
abolabo:
--- Quote from: yonghan79 on April 30, 2021, 06:01:08 AM ---
--- Code: ---foreach ($total_extns as $extn) {
$sf_total_mdl = $this->load->model('total/'.$extn['key'], 'storefront');
/**
* parameters are references!!
*
* @var ModelTotalTotal $sf_total_mdl
*/
$sf_total_mdl->getTotal($total_data, $total, $taxes, $this->cust_data);
//trick to change data via hooks
$this->data = [
'total_key' => $extn['key'],
'total_data' => $total_data,
'total' => $total,
'taxes' => $taxes,
];
$this->registry->get('extensions')->hk_ProcessData($this, __FUNCTION__, ['total_text_id' => $extn]);
$total_data = $this->data['total_data'];
$total = $this->data['total'];
$taxes = $this->data['taxes'];
unset(
$this->data['total_key'],
$this->data['total_data'],
$this->data['total'],
$this->data['taxes']
);
$sf_total_mdl = null;
}
--- End code ---
I see there is //trick to change data via hooks.
--- End quote ---
oh.. yes..
did you tried ?
public function onACart_ProcessData(){
}
yonghan79:
I am testing the ACart_ProcessData but i don't know how to add data to that hook. What is the ['total_text_id' => $extn] used for?
Do you mind giving me an example?
abolabo:
--- Quote from: yonghan79 on April 30, 2021, 06:08:35 AM ---I am testing the ACart_ProcessData but i don't know how to add data to that hook. What is the ['total_text_id' => $extn] used for?
Do you mind giving me an example?
--- End quote ---
public function onACart_ProcessData(){
$that = $this->baseObject;
//change $this->data property of ACart object is PUBLIC
// $that->data = ....your code here
}
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version