item properties not being set

Highlighted
New Member
5 0 0

Hi Shopify community,

 

Having a perplexing issue here; I can't seem to assign line_item properties. I've used the syntax described here before, and even have some success in using it in a snippet that goes into my product-template.liquid page

 

Snippet that works to assign item properties:

<div class="cart__row">
  <table id="rx-range1-table" class="rx-table">
      <thead>
        <th>Eye</th>
        <th>Sphere</th>
        <th>Cylinder</th>
        <th>Axis</th>
        <th>Add</th>
        <th>Mono PD</th>
    </thead>
    <tbody>
      <tr>
        <td class="h"><b>Right</b><br>(OD)</td>
        <td class="nh"><input type="number" name="properties[odSphere]" id="odSphere" min=-5 max=2.5 step=0.25 required></td>
        <td class="nh"><input type="number" name="properties[odCyl]" id="odCyl" min=-2 max=0 step=0.25></td>
        <td class="nh"><input type="number" name="properties[odAxis]" id="odAxis" min=0 max=180 step=1 {% if odCyl.value %} required {% endif %}></td>
        <td class="nh"><input type="number" name="properties[odAdd]" id="odAdd" min=0 max=3 step=0.25></td>
        <td class="nh"><input type="number" name="properties[odPD]" id="odPD" min=10 max=45 step=1 required></td>
      </tr>
      <tr>
        <td class="h"><b>Left</b><br>(OS)</td>
        <td class="nh"><input type="number" name="properties[osSphere]" id="osSphere" min=-5 max=2.5 step=0.25 ></td>
        <td class="nh"><input type="number" name="properties[osCyl]" id="osCyl" min=-2 max=0 step=0.25 ></td>
        <td class="nh"><input type="number" name="properties[osAxis]" id="osAxis" min=0 max=180 step=1 {% if osCyl.value %} required {% endif %}></td>
        <td class="nh"><input type="number" name="properties[osAdd]" id="osAdd" min=0 max=3 step=0.25></td>
        <td class="nh"><input type="number" name="properties[osPD]" id="osPD" min=10 max=45 step=1 required></td>
      </tr>
    </tbody>
  </table>
  <div>
  	<p class="subtext"><h7>Sphere:</h7> -5.00 - +2.50 <h7>Cylinder:</h7> -2.00 - 0.00 <h7>Axis:</h7> 0 - 180</p>
  </div>
  <div id="rx_dist">
  	<input type="radio" class="radio_btn" style="margin-top: 20px" id="distance" name="properties[ouDist]" value="distance" checked required> Distance
  	<input type="radio" style="margin-left:20px;" class="radio_btn" style="margin-top: 20px" id="reading" name="properties[ouDist]" value="reading"> Reading
  </div>
  <br>
  <em>For more information on understanding your prescription, click <a target="_blank" href="https://www.specswap.com/pages/how-to-measure-pd">here</a></em>
</div>

 

 

Snippet that doesn't work to assign item properties:

<div>
    <input type="hidden" name="properties[frameBrand]" id="brand" value="{{meta.brand}}">
    <input type="hidden" name="properties[frame_model]" id="model" value="{{meta.model}}">
    <input type="hidden" name="properties[frame_color]" id="color" value="{{meta.color}}">
    <input type="hidden" name="properties[frame_a_val]" id="a_val" value="{{meta.a_val}}">
    <input type="hidden" name="properties[frame_b_val]" id="b_val" value="{{meta.b_val}}">
    <input type="hidden" name="properties[frame_dbl]" id="dbl" value="{{meta.dbl}}">
    <input type="hidden" name="properties[frame_temple]" id="temple" value="{{meta.temple}}">
    <input type="hidden" name="properties[frame_ed_val]" id="ed_val" value="{{meta.ed_val}}">
</div>

Please note that meta seems to be assigned correctly, as I am able to display the values for each of the metafields. This snippet is added directly below the lines of code that display the meta values, so it should still be within scope. 

 

Furthermore, I've been trying to just basically add properties from the product page with the following line in product-template.liquid, and am still not having any success:

<input type="text" name="properties[testProp]" id="testProp">

 

Any help you can provide would be extremely appreciated!

0 Likes