Adding Custom Fields to the Shopify Dashboard

Shopify Partner
140 3 11

I've successfully created a customer metafield: customer.metafields.c_f.proxy_pickup

Goal is allow the customer (logged in) and on the account.liquid template, be able to edit the value of the metafield. I'm trying to use some jquery and the Metafield API to POST this change from the user:

 <form action="/admin/customers/{{ customer.id }}/metafields.json" method="POST" id="custmeta">
    <input type="hidden" name="customer[id]" value="{{ customer.id }}" />
    <input type="text" name="metafield[c_f.proxy_pickup]" value="{{ customer.metafields.c_f.proxy_pickup }}" placeholder="{{ customer.metafields.c_f.proxy_pickup }}" />
    <input type="submit" value="Edit"/>
  </form>

  <script>
    $('form#custmeta').submit(function(e) {
      e.preventDefault();
      $.ajax({
        type: "POST",
        dataType: "json",
        data: $(this).serialize(),
        url: $(this).attr('action'),
        success: function (data) {
          var formValid = (data.status === 'OK');
          if (formValid) {
            var msgs = '';
            for (var i=0;i<data.messages.length;i++) {
              msgs += '-- ' + data.messages[i] + '\n';
            }
            if (msgs > '') {
              alert('SUCCESS WITH MESSAGES:\n\n' + msgs);
            }
            else {
              alert('SUCCESS!');
            }
          }
          else {
            alert('Status: ' + data.status + '\nMessage: ' + data.message);
          }
        },
        error: function (jqXHR, textStatus, errorThrown) {
          alert('AJAX or Server 500 error occurred');
        }
      });
      return false;
    });
  </script>

Currently keep getting the Alert of AJAX or Server 500 error occurred

0 Likes
Shopify Expert
9965 84 1464

Sean - better that you make a new thread as this seems unrelated to the extension. In any case, what you're doing won't work. You're sending data from a page to the API via JS in a browser. You'll be sending cookies in that request.

Any request that updates/adds data will be blocked if it contains cookies.

★ Winning Partner of the Build a Business competition. ★ http://freakdesign.com.au
1 Like
Excursionist
91 1 7

Hi Jason,

I've installed Shopify FD, which is great for the editing metafields. 

One thing though, when i'm editing theme code, the colours have changed and annoyingly the little X on the title of the snippwt tab, has gone invisible, so i cannot see if a tab is saved or not.

Is it an easy fix?

 

0 Likes
Shopify Expert
9965 84 1464

@Tim - This thread is about the Custom Fields extension. If you're talking about ShopifyFD there's another thread for that. That said, if an Admin update has created a bug/issue posting some extra details here would help for troubleshoot. The more info the better.

★ Winning Partner of the Build a Business competition. ★ http://freakdesign.com.au
0 Likes
New Member
1 0 0

I'm new to Shopify and i have designed my website but now i want to choose some options of another web design but it doesn't work on my site. what should i do? like change the whole theme!

0 Likes
New Member
7 0 0

 

#Jason

Admin/General / Store Metafields is no longer found in Shopify. Where do we create the metafields?

By thy way have you been able to add file upload function? I only want to use that.

Thank you 

0 Likes
Highlighted
Navigator
1151 0 118

On the first Q: admin/settings/general

1. Settings (left menu, bottom)

2. General (top left of menu choices in the center of page)

 

http://www.StandoutDesigns.com ::: Solid Wood TV Furniture for Enthusiasts. Made in USA.
0 Likes
New Member
7 0 0

I dont have it .Is it because I live outside of USA?  

0 Likes
New Member
7 0 0

here is my setting picture : https://ibb.co/hM0mV8

0 Likes