WooCommerce: cambia l'ordine di visualizzazione della descrizione breve del prodotto e del prezzo
1 risposta
- voti
-
- 2015-10-27
Seguardi
woocommerce/templates/content-single-product.php
vedrai cheil riepilogo delprodotto è costruito utilizzando hook conpriorità diverse.Ecco la sezionepertinente:
<?php /** * woocommerce_single_product_summary hook * * @hooked woocommerce_template_single_title - 5 * @hooked woocommerce_template_single_rating - 10 * @hooked woocommerce_template_single_price - 10 * @hooked woocommerce_template_single_excerpt - 20 * @hooked woocommerce_template_single_add_to_cart - 30 * @hooked woocommerce_template_single_meta - 40 * @hooked woocommerce_template_single_sharing - 50 */ do_action( 'woocommerce_single_product_summary' ); ?>
Ilprezzo ha unapriorità di 10,l'estratto ha unapriorità di 20. Per scambiarli,cambia leprioritàmodificando le azioninel
functions.php
deltuo childtheme.In questomodo:
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 ); remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20 ); add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 10 ); add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 20 );
If you look at
woocommerce/templates/content-single-product.php
you'll see that the product summary is constructed using hooks with different priorities.Here's the relevant section:
<?php /** * woocommerce_single_product_summary hook * * @hooked woocommerce_template_single_title - 5 * @hooked woocommerce_template_single_rating - 10 * @hooked woocommerce_template_single_price - 10 * @hooked woocommerce_template_single_excerpt - 20 * @hooked woocommerce_template_single_add_to_cart - 30 * @hooked woocommerce_template_single_meta - 40 * @hooked woocommerce_template_single_sharing - 50 */ do_action( 'woocommerce_single_product_summary' ); ?>
The price has a priority of 10, the excerpt has a priority of 20. To swap them around, change the priorities by modifying the actions in your child theme's
functions.php
.Like this:
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 ); remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20 ); add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 10 ); add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 20 );
-
Seiforte!Grazieper lafantastica spiegazionee soluzione :)You ROCK! Thanks for the awesome explanation and solution :)
- 6
- 2015-10-27
- Kane
Vorrei spostareilprezzo "$ 4,99– $ 24,99" sotto la descrizionebreve delprodotto "Sul serio. Bevi unatazza di questo ..."
Immagine sotto NSFW (linguaper adulti)
Qualcheidea su comefarlo?Hogià un childtheme,manon sono sicuro di qualefile WooCommerce debbaessere sovrascritto.