@SMEG – ich glaube nicht, dass Du die Metafields-Bezeichnung rausbekommst … das hier ist die Objektstruktur, die vom JSON ausgespuckt wird – die Bezeichnung findet sich darin nicht:
das ist ein interessanter Ansatz. Ich habe jetzt doch alles in einzelne Anweisungen gepackt und die for-schleife verworfen. Also schreibe ich jetzt für jedes Metafield
Eigentlich hatte ich mir vorgestellt nicht jedesmal in den Code gehen zu müssen, wenn ein Metafield neu hinzukommt. Aber weder bei deiner noch bei meiner Lösung lässt sich das vermeiden.
Ich habe auch versucht den Key im Metafield schon so zu erstellen wie ich ihn später verwenden möchte und ihn mit “replace” und mit “capitalize” umzuschreiben, aber auch da bin ich nicht weiter gekommen. Ich bekomme zwar den Unterstrich durch ein Leerzeichen ersetzt, aber dann nur das erste Wort groß geschrieben.
Zudem birgt diese Lösung die Gefahr, dass man die Bezeichnung der Attribute, wenn sie aus dem Metafield-Key stammen nicht mehr nachträglich ändern kann. Mann müsste dann das Metafield neu erstellen und die Attribute kopieren. Das ist ja dann noch mehr Arbeit als im Code zu wurschteln.
In der Summe ist es eigentlich Schade, dass es nicht geht den Namen oder die Beschreibung des Metafields anzuzeigen. Produkt-Attribute sind eine ganz klare Anwendung hierfür und z.B. Woocommerce hat sogar eine spezielle Attributs-Funktion bei Produkten (zusätzlich zu Kategorien und Tags).
Wenn ihr mir einen verständlichen Text hier zusammenfasst nach der folgenden Vorlage, dann kann ich das an unsere Product Teams weiterleiten die das dann für die Entwickler Teams übersetzen werden.
Wenn nach dem folgenden Schema und Beispiel wäre super:
Clear problem description, use-cases, and w****hat is needed
Beispiel: One major column of information is missing from the finances report when you click on Total Sales and export the full report. The field “Tax Rate” with a breakdown of whether the item has 20%, 0%, 10%, etc. in taxes would be great if it was there.
Why is this important?
It’s a hassle to go back to a 3rd party app now, even though this data breakdown is actually natively included in Shopify.
@Gabe hier, auch direkt in englisch
Mario ( @r8r ) kann es ja ergänzen, wenn er meint das fehlt was.
Clear problem description, use-cases, and w****hat is needed
Make Name of Metafields available in liquid.
When setting up Metafields for product attributes (think e.g. a watch. It has wristband color, wristband size, wristband material, clock face material, clock face color, frame material, frame color, water resitance, calender, size and many more) I have them all under one namespace “attributes”. I want to iterate through this namespace with a for loop like shown below (last paragraph) and be able to display the value of the Metafield and the name of the Metafield. The Name serves as the attribute label, which is displayed in an attribute list like so:
Right now I can only display Metafield key and Metafield value in the for loop. The key doesn’t provide the necessary flexibility as the Metafield name does. Once the Metafield has been defined the key ist set and can not be changed. Also the String filter aren’t flexibel enough to format the key to the display I want. If I set the key e.g. to nose_gap, I can replace the underscore with whitespace but only capitalize the first letter with “capitalize” (I could do it with CSS, but that would be a workaround again and still wouldn’t make the key flexibel as explained in the next paragraph).
Why is this important?
Product Attributes are an important part of any product. They can easily be set up through the Metafields, but they need to be more flexibel. If an attribute label has to be changed the Merchant has either to set up a new Metafield (if he somehow can get the key to display in a properly format, which I couldn’t manage to do in liquid alone) and copy all values to the new Metafield or the label has to be changed in the code, which is not the best solution, since changing the Metafield name could easily change the attribute label in code (if it was available in code).
What workaround(s) are there?
right now the code becomes messy because the above mentioned for loop can not really be used and the combination of attribute label and Metafield/attribute value has to be put into code for each attribute/Metafield. Just imagine having a bloated code with attributes for the watch mentioned in the first section.
If we could access the Metafield name and use it as a label we could write more efficient code to display a specification/attributes list.
What I would like to code:
{% for field in product.metafields.attribute %}
*** Metafield Name ***
{{ product.metafields.attribute.chain_length }}
{% endfor %}
What I need to Code now for each attribute/product specification:
wir haben gerade festgestellt, dass die Namen der Metafields nicht ermittelt werden können. Schade!
Ich frage mich, wie wir das Ganze bei mehrsprachigen Shops so integrieren können, dass die Mehrsprachigkeits-App das erkennt, dass der Begriff ebenfalls übersetzt werden muss.
Aus anderen Systemen kenne ich es so, dass hier der Name bzw. die festgelegte Bezeichnung des Attributs/Metafields gelesen und global übersetzt werden kann.
Es wäre toll zu erfahren, wie wir das am besten und nachhaltig integrieren können, sodass beispielsweise der von uns festgelegte Name von Drittanbieter-Apps als zu übersetzende Bezeichnung erkannt wird.