Support

Account

Home Forums Search Search Results for 'woocommerce'

Search Results for 'woocommerce'

reply

  • Hi @ayottepl

    Sorry I can’t be of much help, I don’t read or speak french, although I wish I did.

    The $post issue can be solved by looking on woocomerce’s documentation to find a function which finds the current product ID.

    Knowing the ID will fix the issue, because you can use the ID as a second parameter to the get_field function!

    Thanks
    E

  • Ça fait plaisir!

    Bonne continuité et bon WE @elsappy 🙂


    @elliot
    i think Woocommerce does not use $post for products on archive-products.php.

    Have you any idea what i can use instead of $post? I’ll try to look further more to solve my body class trick for next use of this.

  • Wow tu es un génie ma parole ! Ca fonctionne enfin… C’est peut être une méthode un peu bricolée mais bon ça marche c’est l’essentiel !
    MERCI 1000 fois je vais enfin pouvoir avancer 🙂 🙂

    Bonne journée et bon week-end !

  • Crap.. j’avais tout écris et en voulant ajouter un link ça fermé l’onglet.. ok je recommence mais je vais faire un peu plus court!

    Bonne déduction, dynamique étant le ID selon la catégorie dans laquelle tu te trouves.

    De plus, je crois que comme tu dis, le $post ne s’applique pas dans Woocommerce.

    Tu peux donc utiliser le code que j’ai créé pour aller chercher le ID dans la classe de l’élément <body>

    <?php 
    //Get product_cat id	
    	foreach(get_body_class() as $term){
    		if(preg_match('/term-[0-9]/', $term)){
    			$exploded = explode('term-', $term);
    			$id = $exploded[1];
    		}		
    	}
    ?>

    Ensuite, tu dois créer une variable pour aller chercher ton champ ACF pour chaque catégorie spécifiquement :

    <?php
        $banner = get_field('field_51fbcc4b53e5f', 'product_cat_'.$id);	
    ?>

    Comment aller chercher ce ID (field_51fbcc4b53e5f)?

    Vas dans l’admin, sous Custom fields, et trouve ton champ ACF. Ensuite, clique droit et inspect l’élément. Voici une capture d’écran du ID de mon champ ACF en exemple plus haut :

    http://cl.ly/image/1U1V432w0n46

    Pas très compliqué à trouver 😉

    Donc par la suite tu n’auras aucune difficulté à utiliser ta variable (ici en exemple $banner) comme suit :

    <?php echo $banner ?>

    Voilà!

    J’espère que ça va fonctionner 🙂

    Bonne chance!

  • Merci infiniment pour ta réponse !

    Premier test plutôt concluant je tiens quelque chose grâce à toi : j’ai inséré l’id de l’une des mes catégories (par exemple ma catégorie s’appelle “caramel” dont l’id est 27), jusqu’ici tout va bien, le texte s’affiche.
    Mais voila, j’ai 30 autres (sous-)catégories à éditer et en utilisant le code que tu m’a donné avec l’id de cette catégorie et en paramètrant dans ACF “Taxonomie = Caramel”, ce même texte s’affiche sur toutes les catégories confondues 🙂

    Alors pour en revenir à tes explications, tu dis : “Ensuite, pour le faire dynamique, Elliot a publié un lien utile qui pourrait fonctionner (je ne l’ai pas testé)” : comme je suis assez nulle, pourrais-tu juste me dire ce que tu entends par dynamique ? Et le code que tu m’as donné tu le placerais dans le fichier archive-product aussi ? *

    Je vais me creuser la tête maintenant mais c’est vraiment pas évident ^^ Merci encore, enfin un résultat un peu positif !

    * En fait je pense que dynamique veut dire que l’id changera en fonction de la page de catégorie c’est ça ? Pour le code, je l’ai copié dans archive-product, remplacé ce qu’il fallait comme tu m’as dis, mais ca ne marche pas. Alors j’ai une question un peu bête mais le $post qui est écrit au tout début ça ne fait pas référence aux articles ça ?

  • Bonjour elsappy,

    Pour être capable d’afficher ça dans la page archives, tu dois avoir le ID du terme utilisé pour cette archive.

    Pour ma part j’ai utilisé une fonction php afin de sortir le ID qui apparait dans une des classes du body… c’est pas très propre mais à ce moment là au moins ça fonctionnait 😉

    Tu peux commencer en essayant avec un ID hardcodé peut-être?

    <?php the_field(‘description_categorie_2′, ‘ product_cat_19′); ?> admettons. Je mets 19 à titre d’exemple mais tu vas retrouver cette classe sur ton champ body avec le bon id de page à la place. Par contre, sur ton champ body, le id va être relié à “term-” mais tu te dois d’utiliser product_cat_ pour les champs acf!

    Ensuite, pour le faire dynamique, Elliot a publié un lien utile qui pourrait fonctionner (je ne l’ai pas testé) : http://www.advancedcustomfields.com/resources/how-to/how-to-get-values-from-a-taxonomy-term/

    En utilisant ce code suivant :

    <?php
     
    global $post;
     
    // load all 'category' terms for the post
    $terms = get_the_terms($post->ID, 'category');
     
    // we will use the first term to load ACF data from
    if( !empty($terms) )
    {
    	$term = array_pop($terms);
     
    	$custom_field = get_field('category_image', 'category_' . $term->term_id );
    
    //ici je remplacerais get_field('category_image', 'category_' . $term->term_id
    
    //par get_field('description_categorie_2', 'product_cat_' . $term->term_id
     
    	// do something with $custom_field
    }
     
    ?>

    Tu pourrais obtenir le ID de catégorie que tu as besoin.

    En gros, tu as obligatoirement besoin du 2e paramêtre dans ton “the_field” qui se trouve à pointer la bonne catégorie 🙂

    Bonne chance! N’hésite pas si ça ne fonctionne pas, il y a toujours moyen de s’entraider 😉

  • Bonjour Ayottepl,
    Je constate que tu es français donc j’en profite pour te poser une question puisque j’ai un problème presque similaire : je suis en train de faire ma boutique sur Woocommerce et dans mon cas je voudrais ajouter une seconde description de catégorie tout en bas de mes pages de catégorie.
    J’ai donc paramétré un champ Wysiwyg et créé la règle suivante :
    Term est égal à Catégories
    Dans mon template archive-product.php, j’ai ajouté le code suivant : <?php the_field(‘description_categorie_2’); ?>

    L’éditeur Wysiwyg s’affiche parfaitement dans l’admin, je peux éditer mon texte et l’enregistrer sans problème, mais côté front-office rien se passe ! J’avoue que je suis débutante en php et je n’y connais pas grand chose (donc j’ai eu un peu de mal à comprendre comment tu as résolu ton problème :D). Si jamais tu as une idée pour mon problème je t’en serais grandement reconnaissante parce que comme toi je m’arrache les cheveux depuis des jours et des jours….

    Bonne journée,
    Elsa

  • Hi Elliot,

    Thanks for your reply!
    Would this be possible to do manually? I’ve been trying to get this to work for so long now, and thought I’d cracked it using the acf plugin.

    Basically I need to show a piece of code on certain woocommerce category pages, but I can’t use the conditional statement is_product_cat within the single product page template.

    If you could advise me on the manual code I would need to add, in order to show a custom field, maybe I could rework it so that it resolves my issue?

    Any help would be greatly appreciated!

  • It turns out it was an issue with WooCommerce’s function returning the correct taxonomy id. I appreciate the help and sorry for the false alarm.

  • Hi @texasfight

    Thanks for teh question, unfortunately, without looking through the add-on myself, I’m not sure how the custom field values are saved / loaded / rendered in the woocomerce environment.

    Perhaps you could ask the support team of the add-on you purchased?

    Thanks
    E

  • Hi @Fulvio

    Looking for a web developer? I would jump on google for that.

    Thanks for your feedback

    Cheers
    E

  • Uh, alright. By the way thank you for taking out the time for developing and maintaining such an awesome plugin.

    Thanks again

  • Thanks Elliot. I’m using extensively ACF in my WooCommerce setup. Now I’m the process of rebuilding the whole cart using ACF and custom forms, because my products have many meta and need specific user inputs. It’d be nice to organize these in the order post, but for this part I might have some limitations. Do you know where I could get freelancer help? Perhaps you could open a forum section just for that.

    ps – somewhat related: I’ve read your latest blog post http://www.advancedcustomfields.com/blog/planning-future-thoughts-ideas-version-5/ and I’m very excited about this news. Maybe if you are looking for ideas you could further discuss it with your user base.

  • Hi @Fulvio

    Very interesting. Personally, I haven’t tried this before, but hopefully someone can post their findings here.

    Thanks
    E

  • Hi @scorcher

    This is unfortunately out of scope for the ACF plugin. You will need to read up on the woo-commerce documentation to learn if and how you can extend the custom fields for a variation.

    Thanks
    E

  • An Woocommerce ‘My Account’ file. Sits in mytheme/woocommerce/.

    Like I say, it works fine when I have the ID of the page in there so it can communicate fine with the global data. Just cannot get username as $other_page.

  • Hi @oscarf

    I haven’t had much experience with CRMs before, but hopefuly someone else can answer this.

    Just incase no one does, perhaps post this question on a more general WP forum such as stack overflow.

    Thanks
    E

  • I’m having the same issues. I’m using WooCommerce, WPML and ACF. WooCommerce creates a custom taxonomy called ‘product_cat’. The name of the field I’m trying to get is ‘Subscribe Field Name’.

    I’m using the following, but it’s not returning anything:
    <?php echo get_field('subscribe_field_name', 'product_cat_16');?>

    It’s driving me crazy.

  • Hi @ayottepl

    Thanks you very much for sharing this with us!

    I wonder if you read over this guide:
    http://www.advancedcustomfields.com/resources/how-to/how-to-get-values-from-a-taxonomy-term/

    On that page, there is code to find the current term ID / taxonomy, etc

    This would help clean up your body_class code!

  • Hi @trenee71

    All WP images have an ID.
    With this ID you can load any ACF data (please see documentation)
    With WooCommerce, you can load the thumbnail of the product just like in WP

    This is not a limitation of ACF. Just some simple front end code

    Good luck

  • P.S. If you’re able to work this through with me, it could become a great add-on for you to sell for WooCommerce shops…

    Thanks,
    Tiff

  • Hi, I’m not sure if this a stack exchange question because I don’t know if I’ve done all I can using ACF yet.

    I’ve attached screen grabs of what I accomplished using ACF. The first shows the Feature Hover Image custom field with the uploaded image of the chair graphic in the right corner. Part one of what needed to happen.

    The second image shows the settings for the custom field as a reference.

    Because this is a feature image of a product item in WooCommerce and not a typical page or post I am unsure how to get that feature hover image to appear when that product shows on the shop pages. What kind of ACF code would I use to edit the WooCommerce product template?

    Right now the product feature images just have a transparent hover effect. I would like them to have my specific Feature Hover Image instead. Example of product page in the link below…

    http://oxgut.com/wp2013/product-category/products/

    Thanks,
    Tiff

  • I’m afraid changing “category_” to “product_brand_” had no effect. It’s almost like that line has no way of getting the id of the current term. The address reads like this http://site/?product_brand=1st-call-mobility where “1st-call-mobility” is the term of the product_brand taxonomy.

    “contact_info” is my ACF field slug, and “Brands” is a Custom taxonomy, whose slug is “product_brand”. Its a Woocommerce plugin, essentially for adding manufacturers to Woocommerce products.

    I’ve tried printing this code before and it just wasn’t picking up the terms custom field in the print either.

    Do I perhaps need to define “$custom_field” somewhere?

Viewing 23 results - 1,301 through 1,323 (of 1,323 total)