Masquer les prix et la fonctionnalité de paiement dans woocommerce
3 réponses
- votes
-
- 2013-03-15
Heureusement,woocommerce a denombreux hooks,cela supprime lesprixet lesboutons:
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart' ); remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 ); remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 ); remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 );
vouspouvez consulter
content-product.php
etcontent-single-product.php
si vous avezbesoin de supprimer d'autres éléments.J'imagine qu'il y aplus que lesprix/boutons que vous souhaitezmasquer/supprimer (comme lespages/fonctions), cetutoriel vous donne quelques conseils
luckily woocommerce has many hooks, this removes prices and buttons:
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart' ); remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 ); remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 ); remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 );
you can dig into
content-product.php
andcontent-single-product.php
if you need to remove more stuff.I can imagine there's more than just the prices/buttons you want to hide/remove though (like pages/functions), this tutorial gives you some pointers
-
Ai-je raison depenser que ces crochets doivent êtreinsérés dansfunctions.php?Si oui,y a-t-il une sectionparticulière dans laquelleje dois lesmettre?S'ilsfonctionnent,lafonctionnalité dupanierne seraprobablementplus visible,àpart un certain style,n'est-cepas?Am I right in thinking those hooks have to be inserted into functions.php? If so, is there a particular section I need to put them in to? If they work, presumably the cart functionality will no longer be visible, aside from some styling, is that right?
- 0
- 2013-12-01
- James
-
oui,vouspouvez lesmettre dansfunctions.phpet peuimporte où vous lesmettez dans une autrefonction.Habituellement,tout le chemin à lafin dufichierest leplus sûr,tant que vousne lesmettezpas après le dernier `?>`.Celane supprimerapas lapage dupanier,mais supprimeraen fait lapossibilité d'ajouter quoi que ce soit aupanier.Si vousn'aimezpas lapage dupanier,vous devriez être relativementen sécurité.yes, you can put them in functions.php and it doesn't matter where you put them within another function. Usually all the way at the end of the file is the safest, as long as you don't put them after the last `?>`. This will not remove the cart page, but it will actually remove the possibility of adding anything to the cart. If you don't like the cart page anywhere you should be relatively safe.
- 1
- 2013-12-05
- Ewout
-
Çamarche.Mais c'est étrange.Après avoir appliqué cela,lesimages duproduitne s'affichentplus.Ilmontre unespace videpour leuremplacement,et quandje passe la souris dessuset clique dessus,ilsme montrent l'image appropriée.Avez-vous uneidée depourquoi cela seproduit?It works. But this is strange. After applying this, the product images stopped from appear. It shows an empty space for theirs location, and when i pass the mouse over them and click them they show me the proper image. Do you have an idea on why is that happening?
- 0
- 2016-08-02
- Brethlosze
-
- 2013-12-15
Enprolongeant le code ci-dessus (merci Ewout),le code suivant supprimeratous lesprixet lesboutons «Ajouter aupanier» surtous lesproduits woocommerce,ainsi que d'expliquerpourquoi. J'avaisbesoin du codepour un site Web quipropose desproduits de vente directeet pourme conformer à leurs règles,je nepeuxpas afficher lesprix augrandpublic.
Ajoutez lefiltre aufichierfunctions.php de votrethème.
add_filter('woocommerce_get_price_html','members_only_price'); function members_only_price($price){ if(is_user_logged_in() ){ return $price; } else { remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart' ); remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 ); remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 ); remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 ); return 'Only <a href="' .get_permalink(woocommerce_get_page_id('myaccount')). '">Registered Users</a> are able to view pricing.'; } }
Extending the above code (thanks Ewout), the following code will get rid of all prices and 'add to cart' buttons on all woocommerce products, as well as provide an explanation as to why. I needed the code for a website that offers direct selling products and to comply with their rules, I cannot show prices to the general public.
Add the filter to your theme's functions.php file.
add_filter('woocommerce_get_price_html','members_only_price'); function members_only_price($price){ if(is_user_logged_in() ){ return $price; } else { remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart' ); remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 ); remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 ); remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 ); return 'Only <a href="' .get_permalink(woocommerce_get_page_id('myaccount')). '">Registered Users</a> are able to view pricing.'; } }
-
Celaest étrange.Après avoir appliqué cela,lesimages duproduitne s'affichentplus.Ilmontre unespace videpour leuremplacement,et quandje passe la souris dessuset clique dessus,ilsme montrent l'image appropriée.Avez-vous uneidée depourquoi cela seproduit?This is strange. After applying this, the product images stopped from appear. It shows an empty space for theirs location, and when i pass the mouse over them and click them they show me the proper image. Do you have an idea on why is that happening?
- 0
- 2016-08-02
- Brethlosze
-
Ce codene fonctionnepas dans WooCommerce v`3.2.1` :-)This code does not work in WooCommerce v`3.2.1` :-)
- 0
- 2017-10-19
- Steve
-
- 2017-08-22
add_filter( 'woocommerce_is_purchasable', '__return_false' ); add_filter( 'woocommerce_get_price_html', '__return_empty_string' );
Celaempêcheratotalement lepaiementet masqueratous lesprixpar:
- Rendretous lesproduitsnon achetables (ligne 1)
- Prix de vidage HTML (ligne 2)
add_filter( 'woocommerce_is_purchasable', '__return_false' ); add_filter( 'woocommerce_get_price_html', '__return_empty_string' );
This will totally prevent checkout and hide all prices by:
- Making all product non-purchasable (line 1)
- Emptying price HTML (line 2)
Je sais que cette questionestpeut-êtretrop large,maisje cherche unpeu d’orientation.Mon client a unmagasin woocommerce avec 30 à 40produits.Pour une raison quelconque,ilsne veulentplus vendreen ligne,maisils veulent conserver lespagesproduits,lesinformations,etc. sur leur site Web.
Existe-t-il unmoyen,en utilisant des crochets ou autrement,demasquer des choses comme lesprix,lebouton Ajouter aupanier,etc. dans woocommerce?Ou devrais-je simplementmodifier lesfichiers demodèlephp?