Prijs komt dubbel voor
-
Hoi iedereen,
Voor mijn shop verkoop ik variabele producten en losse producten.
Bij mijn variabele producten laat hij nu alleen de prijs zien als je een optie hebt geselecteerd (6 of 12 stuks).
Bij een hele product laat hij de prijs alleen dubbbel zien. Ik heb hiervoor de volgende code gebruikt.
<blockquote cite=”
//Hide Price Range for WooCommerce Variable Products
add_filter( ‘woocommerce_variable_sale_price_html’,
‘lw_variable_product_price’, 10, 2 );
add_filter( ‘woocommerce_variable_price_html’,
‘lw_variable_product_price’, 10, 2 );function lw_variable_product_price( $v_price, $v_product ) {
// Product Price
$prod_prices = array( $v_product->get_variation_price( ‘min’, true ),
$v_product->get_variation_price( ‘max’, true ) );
$prod_price = $prod_prices[0]!==$prod_prices[1] ? sprintf(__(‘6 of 12 stuks’, ‘woocommerce’),
wc_price( $prod_prices[0] ) ) : wc_price( $prod_prices[0] );// Regular Price
$regular_prices = array( $v_product->get_variation_regular_price( ‘min’, true ),
$v_product->get_variation_regular_price( ‘max’, true ) );
sort( $regular_prices );
$regular_price = $regular_prices[0]!==$regular_prices[1] ? sprintf(__(‘From: %1$s’,’woocommerce’)
, wc_price( $regular_prices[0] ) ) : wc_price( $regular_prices[0] );if ( $prod_price !== $regular_price ) {
$prod_price = ‘‘.$regular_price.$v_product->get_price_suffix() . ‘<ins>’ .
$prod_price . $v_product->get_price_suffix() . ‘</ins>’;
}
return $prod_price;
}//Hide “From:$X”
add_filter(‘woocommerce_get_price_html’, ‘lw_hide_variation_price’, 10, 2);
function lw_hide_variation_price( $v_price, $v_product ) {
$v_product_types = array( ‘variable’);
if ( in_array ( $v_product->product_type, $v_product_types ) && !(is_shop()) ) {
return ”;
}
// return regular price
return $v_price;
}function move_price(){
?>
<script>
jQuery(window).load(function(){
jQuery( ‘.single-product.woocommerce-page’ ).each(function() {
jQuery( this ).find( ‘.av-woo-purchase-button .woocommerce-Price-amount’ ).insertBefore( jQuery(this).find(‘.special-heading-border’) );
});
});
</script><?php
}
add_action(‘wp_footer’, ‘move_price’);//remove display notice – Showing all x results
remove_action( ‘woocommerce_before_shop_loop’, ‘woocommerce_result_count’, 20 );
//remove default sorting drop-down from WooCommerce
remove_action( ‘woocommerce_before_shop_loop’, ‘woocommerce_catalog_ordering’, 30 );
“>Enig idee hoe ik bij 1 losstaand product de prijs 1 malig kan laten zien?
Alvast bedankt!
-
Dit forum bied alleen ondersteuning voor WordPress.com sites. Ondersteuning voor het WooCommerce plugin vind je op https://wordpress.org/support/plugin/woocommerce/.
- Het onderwerp ‘Prijs komt dubbel voor’ is gesloten voor nieuwe reacties.