- Posts: 49
- Thank you received: 0
Redirect in checkout for only one product
- Clarenceljw
-
Topic Author
- Offline
Hi,
I would like to create a redirect to a landing page in checkout, but I want it to only apply to one product. In other words, I do not want the redirect on any other product other than a product I choose. How may I do this?
Thank you for your kind attention.
Please Log in or Create an account to join the conversation.
Can precise your idea please ?
You mean create a button link to checkout in only one product page ? OR only have a redirection (with add to cart button) in checkout for one product and not other ?
More precisely, does have a button (add to cart button) with another text like "Go to checkout" AND the automatic redirection to checkout (thanks to the "After a product is added to the cart" option) only in one product page, can be for you a good solution ?
Awaiting news from you.
Regards
Please Log in or Create an account to join the conversation.
- Clarenceljw
-
Topic Author
- Offline
- Posts: 49
- Thank you received: 0
I want the redirect to occur when customers press "finish" and they also have that specific product in their cart. In other words, if they have the product "Content Marketing for Social Media" in their cart and they buy it, I want a redirect to a landing page to occur. But I only want the redirect if this specific product is in the cart. If there are other products in the cart, but not this product, I do not want a redirect.
I hope this is clearer.
Also can you tell me how to get rid of the "Additional Information" section (you can see it in the attachment)? I only sell digital products and don't need comments or delivery date in my order form. I look forward to your help. Thank you.
Please Log in or Create an account to join the conversation.
- Posts: 12953
- Thank you received: 1778
1. There is actually no option to do it and it will require some code customization if you want your customers to be redirected :
- After pressing "Finish" then you'll have to edit the code of your Payment plugins
- After they reach the thank you page, then you'll have to directly edit the code of the "after_end" file of the "checkout" view of your front-end template via "Hikashop->Display->Views."
2. To remove the "Additional Information" section you'll have to remove the "Field" action from your checkout workflow via "Hikashop->System->Configuration->Checkout".
Please Log in or Create an account to join the conversation.
- Clarenceljw
-
Topic Author
- Offline
- Posts: 49
- Thank you received: 0
Please Log in or Create an account to join the conversation.
There, you can loop through the products of the order in $this->order->products and check their ID or code or name and then do a Joomla redirect:
snipt.net/esedic/how-to-redirect-using-the-joomla-api/
Please Log in or Create an account to join the conversation.
- Clarenceljw
-
Topic Author
- Offline
- Posts: 49
- Thank you received: 0
Can you give me a sample code for "$this->order->products"? Where does the product ID go?
Thanks.
Please Log in or Create an account to join the conversation.
It's simple standard PHP to loop through an array of elements. For example:
Please Log in or Create an account to join the conversation.
- Clarenceljw
-
Topic Author
- Offline
- Posts: 49
- Thank you received: 0
I'm sorry to bother you, but where do I find the product ID?
Thanks.
Please Log in or Create an account to join the conversation.
It's in that variable: $product->product_id
You can see it in the URL when you edit a product.
But you can do the check on the product_code instead if you want. It will work the same and you already know them.
Please Log in or Create an account to join the conversation.
- Clarenceljw
-
Topic Author
- Offline
- Posts: 49
- Thank you received: 0
Thank you for your help so far. Unfortunately, I do not know PHP. Can you please tell me if there is anything wrong with the code below?
Thank you again for helping me.
Please Log in or Create an account to join the conversation.
You need to write 'CMSM1' not just CMSM1.
The rest looks fine.
Please Log in or Create an account to join the conversation.
- Clarenceljw
-
Topic Author
- Offline
- Posts: 49
- Thank you received: 0
I've made the change, but the redirect isn't working. Nothing happens. Can you help me figure out what's wrong?
The full code to be debugged is below:
Please Log in or Create an account to join the conversation.
Try with :
if($product->order_product_code == 'CMSM1'){
instead of:
if($product->product_code == 'CMSM1'){
Please Log in or Create an account to join the conversation.
- Clarenceljw
-
Topic Author
- Offline
- Posts: 49
- Thank you received: 0
It works now! Thank you!
Please Log in or Create an account to join the conversation.