cancel
Showing results for 
Search instead for 
Did you mean: 

Add orders comment corresponding to store url visited

SOLVED

Add orders comment corresponding to store url visited

Hi there,

 

I would like to know if there is a way to know from where a store is viewed.
What I plan to do is setting multiple qrcodes/url that would redirect to the same store and setting to the orders a parameter corresponding to the ID of the qrcode/url visited.

Let's say base store url is : https://shop/magento/store/
If url1 from site X is visited, then it would redirect to something like https://shop/magento/store/1 and/or adding a comment/status for the orders saying the order is from url1.

If url2 from qrcode2 is visited, then it would add the comment/status/other corresponding to url2.

If base url is visited, nothing would be added.

I will be glad to know what I can do to perform this.

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Add orders comment corresponding to store url visited

Hello @anthonyalb38ed 

 

I can give you some rough idea with breakdown so you can know how it can be done,

 

1. You must pass some data from 3rd party to your website like below :

 

www.DOMAIN.com/?ANY_VARIABLE=VARIABLE_VALUE

Here you can see there is one parameter ANY_VARIABLE = VARIABLE_REFERENCE_VALUE ,

 

you can set it according to you or any reference value passed from 3rd party.

 

2. You should add a Javascript code which will work in all pages of your website, so it will fetch cookie from URL, if it finds ANY_VARIABLE then it will set a cookie in cookies.

 

3. Now you have cookie set, so your website knows for short period that it came from a different URL, you must add a new order attribute, i. e. there must be a column in sales_order table which will store the data.

Reference : https://magento.stackexchange.com/questions/131935/magento-2-how-to-create-new-order-attribute-progr...

 

4. Now you have an empty column in sales order, you just need to use a Events , You can use checkout_submit_all_after which will trigger right after any order is placed.

Example : https://community.magento.com/t5/Magento-2-x-Programming/Observer-module-checkout-submit-all-after/t...

User cookie manager or some to retrieve data in your observer and base on that you can save that value to your order table.

 

Now you can explore based on keywords, Good luck ~ Smiley Happy

Hope it helps !

Problem Solved ? Click on 'Kudos' & Accept as Solution ! Smiley Happy

View solution in original post

4 REPLIES 4

Re: Add orders comment corresponding to store url visited

Hello @anthonyalb38ed 

 

If you are managing from where it is coming from, you can pass some some GET variables in URL and save in cookie or session then you can create a after/plugin order functionality to check if cookie has that data set then based on that you can store data.

 

Hope it helps !

Problem Solved ? Click on 'Kudos' & Accept as Solution ! Smiley Happy

Re: Add orders comment corresponding to store url visited

Hi @gaurav_harsh1 ,
Thank you for your answer I really appreciate it.

I understand the idea behind your comment, it will help a lot, but as I have almost 0 knowledge in Magento it is a bit blurry.

How can I create a after/plugin order? Where shall I store this file?

I guess I have some more digging to perform but you surely put my on rails.

Re: Add orders comment corresponding to store url visited

Hello @anthonyalb38ed 

 

I can give you some rough idea with breakdown so you can know how it can be done,

 

1. You must pass some data from 3rd party to your website like below :

 

www.DOMAIN.com/?ANY_VARIABLE=VARIABLE_VALUE

Here you can see there is one parameter ANY_VARIABLE = VARIABLE_REFERENCE_VALUE ,

 

you can set it according to you or any reference value passed from 3rd party.

 

2. You should add a Javascript code which will work in all pages of your website, so it will fetch cookie from URL, if it finds ANY_VARIABLE then it will set a cookie in cookies.

 

3. Now you have cookie set, so your website knows for short period that it came from a different URL, you must add a new order attribute, i. e. there must be a column in sales_order table which will store the data.

Reference : https://magento.stackexchange.com/questions/131935/magento-2-how-to-create-new-order-attribute-progr...

 

4. Now you have an empty column in sales order, you just need to use a Events , You can use checkout_submit_all_after which will trigger right after any order is placed.

Example : https://community.magento.com/t5/Magento-2-x-Programming/Observer-module-checkout-submit-all-after/t...

User cookie manager or some to retrieve data in your observer and base on that you can save that value to your order table.

 

Now you can explore based on keywords, Good luck ~ Smiley Happy

Hope it helps !

Problem Solved ? Click on 'Kudos' & Accept as Solution ! Smiley Happy

Re: Add orders comment corresponding to store url visited

Thank you very much for your valuable infos.

This will definitely help me looking for what I need !