Solved

Passing custom variable form product to cart page

Chisty
Excursionist
18 0 5

So I have installed a script that shows a "completion date" on the product page

 

How do I go about passing that custom variable onto the cart page, so it is recorded with their order?

 

I am a real novice, so please don't confuse me , thinking I'm on your level LOL

 

Thanks in advance. 

 

 
</script>

    
            
                          <h4>Your estimated date for completion is </h4>
          <h4 id="new"></h4>


<script>
var d = new Date();
d.setDate(d.getDate() + 30);
var months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
var date = d.getDate()+' '+months[d.getMonth()]+', '+d.getFullYear(); 
document.getElementById("new").innerHTML = date;
  
  

  
  
  
  
  
  
  
</script>
 
Accepted Solution (1)

Developer-G
Shopify Partner
3039 594 846

This is an accepted solution.

Hello 

Add this under form tag

  <input id="estimated-date" type="hidden" name="properties[estimated date]">

And replace your script to this

<script>
var d = new Date();
d.setDate(d.getDate() + 30);
var months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
var date = d.getDate()+' '+months[d.getMonth()]+', '+d.getFullYear(); 
document.getElementById("new").innerHTML = date;
document.getElementById("estimated-date").value = date;
</script>

Thanks

- If helpful then please Like and Accept Solution.
- Want to modify or custom changes or bug fix on store Hire me.
- Email: guleriathakur43@gmail.com - Skype: navrocks1 ,
- Try GEMPAGES a great page builder
-Advance Search Filter

View solution in original post

Replies 5 (5)

Developer-G
Shopify Partner
3039 594 846

This is an accepted solution.

Hello 

Add this under form tag

  <input id="estimated-date" type="hidden" name="properties[estimated date]">

And replace your script to this

<script>
var d = new Date();
d.setDate(d.getDate() + 30);
var months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
var date = d.getDate()+' '+months[d.getMonth()]+', '+d.getFullYear(); 
document.getElementById("new").innerHTML = date;
document.getElementById("estimated-date").value = date;
</script>

Thanks

- If helpful then please Like and Accept Solution.
- Want to modify or custom changes or bug fix on store Hire me.
- Email: guleriathakur43@gmail.com - Skype: navrocks1 ,
- Try GEMPAGES a great page builder
-Advance Search Filter
Chisty
Excursionist
18 0 5

Thanks so much, that is working perfectly.

laxmom
Tourist
10 0 2

What file did you edit with this script?

PamalaLavan
Visitor
1 0 0

Hi the .innerHTML = "ABC" is not working on the Shopify pages

 

Any ideas ?

david-kaplan
Shopify Partner
12 0 0

Hello PamalaLavan, 

in what context the.innerHTML="ABC" does not work? It is a valid JS code and it should work. 

1. Check if you are selecting an element correctly. 

2. Check if you are not giving value to this element in a different parts of your code. 

Hope it will help 
David