Parcels in price (10x 12.90)

Home Forums Legacy Support Support queries Other issues Parcels in price (10x 12.90)

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #379229
    marcelodidier
    Spectator
    I need a function to put parcels in price and the final price. I have found a plugin to do that but no sincronize with WPLMS price. Just only a Woocommerce price. http://3.19.56.76 http://3.19.56.76/shop/ - This is ok! But not work in home. I try this but not work: /** * Custom simple product price format. * * Adds credit cart parcels in price html. * * @param string $price Old price format. * * @return string Price format with credit card parcels. */ function cs_custom_simple_product_price_html( $price ) { global $product; $parcels = 12; // Edit the number of parcels here! $parcel_price = $product->get_price() / 12; $html = '<span class="parcels">' . $parcels . 'x </span>'; $html .= wc_price( $parcel_price ) . '<br />'; $html .= '<span class="without-interest">' . __( 'sem juros' ) . '</span><br />'; $html .= wc_price( $product->get_price() ); return $html; } add_filter( 'wc_price_html', 'cs_custom_simple_product_price_html' );
    #379286
    Anshuman Sahu
    Keymaster
    We are using this code :
    $product = wc_get_product( $product_id );
    $product->get_price_html()
    to fetch and show the pricing there . Please check if your custom code works with this or not. you need to use this filter : apply_filters( 'woocommerce_get_price_html', $price, $this );
    #379291
    marcelodidier
    Spectator
    This reply has been marked as private.
    #379377
    Anshuman Sahu
    Keymaster
    Try out this code :
    
    add_filter('woocommerce_get_price_html',function($price,$product){
    	$parcels = 12; // Edit the number of parcels here!
    	$parcel_price = $product->get_price() / 12;
    	$html = '<span class=”parcels”>' . $parcels . 'x </span>';
    	$html .= wc_price( $parcel_price ) . '<br />';
    	$price .= '<span class=”without-interest”>' . __( 'sem juros' ) . '</span><br />';
    
    	return $price;
    },10,2);
    #379412
    marcelodidier
    Spectator
    I made a few small adjustments to work and it worked. add_filter('woocommerce_get_price_html',function($price,$product){ $parcels = 12; // Edit the number of parcels here! $parcel_price = $product->get_price() / 12; $html = '<span class=”parcels”>' . $parcels . 'x </span>'; $html .= wc_price( $parcel_price ) . '<br />'; $price .= '<span class=”without-interest”>' . __( ' sem juros' ) . '</span><br />'; return '<span class=”parcels”>' . $parcels . 'x </span>' . wc_price( $parcel_price ) . ' ou <br />' . $price; },10,2); Thank you so much for your attention and support!
    #379432
    Veronica
    Moderator
    appreciate this thanks for your confirmation
Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Parcels in price (10x 12.90)’ is closed to new replies.