Add to cart link and custom product fields.
- brainforge
-
Topic Author
- Offline
The requirement is to be able to associate the ordered product with the context where the Add to Cart button was clicked. This would be used during post order processing.
The link would then look something like this:
Please Log in or Create an account to join the conversation.
The system would then automatically insert the tracking_id in both tables.
Please Log in or Create an account to join the conversation.
- brainforge
-
Topic Author
- Offline
Please Log in or Create an account to join the conversation.
- Posts: 9
- Thank you received: 0
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
- brainforge
-
Topic Author
- Offline
Note that the quantity could be 0 in some cases!
(b) Is there / could there be a Hikashop helper function so that my own code could add products to the cart?
Something like this:
Please Log in or Create an account to join the conversation.
b/ Sure. You can use the function update of the file administrator/components/com_hikashop/classes/cart.php
But since the items data is taken directly from the request, you will have to set it dynamically in it... Something like that:
$data=array('item'=>$items);
JRequest::setVar('data',$data);
$class = hikashop::get('class.cart');
$class->update($product_id, $quantity);
It's not tested so you might have to adapt that a bit...
Please Log in or Create an account to join the conversation.
- brainforge
-
Topic Author
- Offline
(a) classes/field.php in getInput() lines 234 and 236 (if(!isset($formData))
(b) classes/cart.php in updateEntry() line 356 $already_done2 = true;
I have not tested the rest of the shop functionality so I don't know what might get broken by these changes.
Is it possible to provide a proper long term fix for this please?
E.G. An optional force parameter passed into $class->update() which achieves the same result.
Please Log in or Create an account to join the conversation.
function update($product_id,$quantity=1,$add=0,$type='product',$resetCartWhenUpdate=true,$force=false){
We'll keep it to false by default in order to not alter anything else in HikaShop as the statics in place currently are used to avoid inserting custom item fields data to the options of a product.
Please Log in or Create an account to join the conversation.
- brainforge
-
Topic Author
- Offline
Please Log in or Create an account to join the conversation.
- brainforge
-
Topic Author
- Offline
However, when I create/complete the order it does not get copied through to the corresponding column in the jos_hikashop_order_product table
As a result the onAfterOrderUpdate() and onAfterOrderCreate() triggers in my plug-in cannot see it.
The custom item has Front-End disabled in its definition (I don't want the customer to see it at checkout).
If I change it to enabled then it works fine.
Is this a bug or design feature?
Could it be changed please so that these items allows get copied across to the jos_hikashop_order_product table.
There might also be additional issues with hiding these values in emails, invoices and customer order listings.
Please Log in or Create an account to join the conversation.
You should be able to hide it everywhere with CSS and/or view edition.
Please Log in or Create an account to join the conversation.
- brainforge
-
Topic Author
- Offline
Please Log in or Create an account to join the conversation.
&data[item][custom_item_value_field_name]=Test&data[item][custom_item_value_field_name2]=Test2
Please Log in or Create an account to join the conversation.
Yes, exactly.
Please Log in or Create an account to join the conversation.