WooFrance Dépannage et support WordPress WooCommerce › Forums › Discussion générale › Comment affiché un prix en A partir de …€
- Ce sujet contient 11 réponses, 3 participants et a été mis à jour pour la dernière fois par
Cartier Marine, le il y a 4 années et 8 mois.
-
AuteurMessages
-
22 janvier 2020 à 11 h 12 min #16123822 janvier 2020 à 11 h 21 min #161239
Bonjour,
Il faut mettre ce code dans function php du thème
add_filter( ‘woocommerce_variable_price_html’, ‘bbloomer_variation_price_format_min’, 9999, 2 );
function bbloomer_variation_price_format_min( $price, $product ) {
$prices = $product->get_variation_prices( true );
$min_price = current( $prices[‘price’] );
$price = sprintf( __( ‘a partir de %1$s’, ‘woocommerce’ ), wc_price( $min_price ) );
return $price;
}
====================
22 janvier 2020 à 11 h 24 min #161240Merci mais cela ne fonctionne pas,
j’ai cette erreur,
Uncaught Error: syntax error, unexpected ‘partir’ (T_STRING), expecting ‘,’ or ‘)’ in /home/marine91/chicetfeerique-faire-part.com/wp-content/themes/stationery/functions.php on line 34
- require_once()
wp-config.php:76 - require_once()
wp-load.php:37 - require_once()
wp-blog-header.php:13 - require()
index.php:17
<p style= »line-height: 1.5; margin: 25px 0px 20px; »>Une erreur critique est survenue sur votre site.</p>====================
22 janvier 2020 à 11 h 38 min #16124622 janvier 2020 à 11 h 43 min #161247Voici mon fichier en entier.
j’ai regardé je n’est pas le theme setup, je l’ai mis directement dans le fichier funtions.php de mon thème enfant.
<?php /** * Stationery engine room * * @package stationery */ /** * Set the theme version number as a global variable */ $theme = wp_get_theme( 'stationery' ); $stationery_version = $theme['Version']; $theme = wp_get_theme( 'storefront' ); $storefront_version = $theme['Version']; /** * Load the individual classes required by this theme */ require_once( 'inc/class-stationery.php' ); require_once( 'inc/class-stationery-customizer.php' ); require_once( 'inc/class-stationery-template.php' ); require_once( 'inc/class-stationery-integrations.php' ); require_once( 'inc/plugged.php' ); add_filter( ‘woocommerce_variable_price_html’, ‘bbloomer_variation_price_format_min’, 9999, 2 ); function bbloomer_variation_price_format_min( $price, $product ) { $prices = $product->get_variation_prices( true ); $min_price = current( $prices[‘price’] ); $price = sprintf( __( ‘A partir de %1$s’, ‘woocommerce’ ), wc_price( $min_price ) ); return $price; } /** * Do not add custom code / snippets here. * While Child Themes are generally recommended for customisations, in this case it is not * wise. Modifying this file means that your changes will be lost when an automatic update * of this theme is performed. Instead, add your customisations to a plugin such as * https://github.com/woothemes/theme-customisations */
====================
22 janvier 2020 à 11 h 55 min #161257Utilisez
https://fr.wordpress.org/plugins/code-snippets/ pour ajoutez du code perso
====================
27 janvier 2020 à 18 h 10 min #161256/**
* Do not add custom code / snippets here.
* While Child Themes are generally recommended for customisations, in this case it is not
* wise. Modifying this file means that your changes will be lost when an automatic update
* of this theme is performed. Instead, add your customisations to a plugin such as
* https://github.com/woothemes/theme-customisations
Il est précisé ici de ne pas mettre de code personnalisé. Utilisez plutôt le plugins code snippet pour ajouter du code perso.
====================
27 janvier 2020 à 18 h 17 min #161944Voici mon fichier en entier.
j’ai regardé je n’est pas le theme setup, je l’ai mis directement dans le fichier funtions.php de mon thème enfant.
<?php /** * Stationery engine room * * @package stationery */ /** * Set the theme version number as a global variable */ $theme = wp_get_theme( 'stationery' ); $stationery_version = $theme['Version']; $theme = wp_get_theme( 'storefront' ); $storefront_version = $theme['Version']; /** * Load the individual classes required by this theme */ require_once( 'inc/class-stationery.php' ); require_once( 'inc/class-stationery-customizer.php' ); require_once( 'inc/class-stationery-template.php' ); require_once( 'inc/class-stationery-integrations.php' ); require_once( 'inc/plugged.php' ); add_filter( ‘woocommerce_variable_price_html’, ‘bbloomer_variation_price_format_min’, 9999, 2 ); function bbloomer_variation_price_format_min( $price, $product ) { $prices = $product->get_variation_prices( true ); $min_price = current( $prices[‘price’] ); $price = sprintf( __( ‘A partir de %1$s’, ‘woocommerce’ ), wc_price( $min_price ) ); return $price; } /** * Do not add custom code / snippets here. * While Child Themes are generally recommended for customisations, in this case it is not * wise. Modifying this file means that your changes will be lost when an automatic update * of this theme is performed. Instead, add your customisations to a plugin such as * https://github.com/woothemes/theme-customisations */
Compare les guillemets simples du code que tu as ajouté avec ceux du code précédent.
====================Content(e) de mon aide ? Vous pouvez m'offrir un café ! 🙂
Avant d'appeler à l'aide: Dépannage Woocommerce
1 user thanked author for this post.
27 janvier 2020 à 19 h 07 min #16196317 août 2020 à 11 h 32 min #161139Bonjour,
Avez vous essayer d’ajouter ce code :
/**
* @snippet Variable Product Price Range: "From: $$$min_price"
* @how-to Get CustomizeWoo.com FREE
* @sourcecode https://businessbloomer.com/?p=275
* @author Rodolfo Melogli
* @compatible WooCommerce 3.5.4
* @donate $9 https://businessbloomer.com/bloomer-armada/
*/
add_filter(
'woocommerce_variable_price_html'
,
'bbloomer_variation_price_format_min'
, 9999, 2 );
function
bbloomer_variation_price_format_min(
$price
,
$product
) {
$prices
=
$product
->get_variation_prices( true );
$min_price
= current(
$prices
[
'price'
] );
$price
= sprintf( __(
'A partir de %1$s'
,
'woocommerce'
), wc_price(
$min_price
) );
return
$price
;
}
Dites nous si cela à marché
18 août 2020 à 16 h 26 min #161140Bonjour,
Il faut ajouter le code suivant sur le function.php de votre theme actif
/**
* @snippet Variable Product Price Range: « From: $$$min_price »
* @how-to Get CustomizeWoo.com FREE
* @sourcecode https://businessbloomer.com/?p=275
* @author Rodolfo Melogli
* @compatible WooCommerce 3.5.4
* @donate $9 https://businessbloomer.com/bloomer-armada/
*/add_filter( ‘woocommerce_variable_price_html’, ‘bbloomer_variation_price_format_min’, 9999, 2 );
function bbloomer_variation_price_format_min( $price, $product ) {
$prices = $product->get_variation_prices( true );
$min_price = current( $prices[‘price’] );
$price = sprintf( __( ‘From: %1$s’, ‘woocommerce’ ), wc_price( $min_price ) );
return $price;
}Ca devrait marcher,
Merci
====================
- require_once()
-
AuteurMessages
- Vous devez être connecté pour répondre à ce sujet.