• Resolved Digihood

    (@josif201)


    Hello,

    I need help with your plugin. I am using the woocommerce filter woocommerce_get_price_html to add description to the price.

    What it is suppose to do is to add different price description after the price based on product category and if is it variable product. The filter works fine everywhere on the website. When I turn the plugin off, than I get correct results as well with the default WordPress variation select.

    Can you please help me to make this work with your plugin?

    Thanks,

    Josef

    
    add_filter( 'woocommerce_get_price_html', array( $this,'wpa83367_price_html'), 100, 2 );
    
    /**
    		* 	Description 
    		*
    		* 	@param $price
    		*	  @param $product
    		* 
    		* 	@author Wedesin
    		* 	@return number
    		*/
    		function wpa83367_price_html( $price, $product ){
    						
    			$_price = $product->get_price();
    			$multiplier = get_field( 'fish_percentage_payment', 'options' );
    
    			if ( $_price > 0 ) { 
    
    				if ( $multiplier > 0  ) {
    					//if it is 
    					if ( has_term( 15, 'product_cat', $product->get_id() ) ||
    						has_term( 18, 'product_cat', $product->get_id() ) || 
    						has_term( 22, 'product_cat', $product->get_id() ) ) { 
    						$price = $price . '<span class="text-blue"> ' . __('záloha', 'supinka') . ' ' .$this->calculate_rest_price( $product ) . ' ' .get_woocommerce_currency_symbol() .' ' .__('na místě v?etně DPH/1kg', 'supinka') . '</span>';
    
    						return $price;
    					} else if ( has_term( 19, 'product_cat', $product->get_id() ) ) { 
    						return $price . '<span class="woocommerce-Price-amount">' . __(' v?etně DPH', 'supinka') . '</span>';
    					} else {
    						return $price . '<span class="woocommerce-Price-amount">' . __(' v?etně DPH/1ks', 'supinka') . '</span>';
    					}
    
    				} else {
    
    					$is_variable = $product->is_type( 'variable' );
    					$terms = get_the_terms( $product->get_id(), 'product_cat' );
    
    					//if it is chlazené mo?stké ryby
    					if ( 
    
    						!has_term( 15, 'product_cat', $product->get_id() ) &&
    						!has_term( 18, 'product_cat', $product->get_id() ) && 
    						!has_term( 22, 'product_cat', $product->get_id() ) 
    
    					) { 
    						//issue with DPH per item
    						return $price . '<span class="woocommerce-Price-amount">' . __(' v?etně DPH', 'supinka') . '</span>';
    
    					} else {
    						
    						return $price . ' <span class="woocommerce-Price-amount">' .__('v?etně DPH/1kg', 'supinka') .'</span>';
    
    					}
    
    				}
    
    			}
    		   	
    		}	
    
    
Viewing 1 replies (of 1 total)
  • ashiquzzaman

    (@ashiquzzaman)

    Hi Josef,

    I’m sorry we usually don’t advise on custom codes, partly because we don’t know the nature of custom job users’ trying to achieve and also unexpected error the code might throw that will sometimes give bad impression on us, I hope you understand.

    Regards,
    Ashiq

Viewing 1 replies (of 1 total)
  • The topic ‘woocommerce_get_price_html filter not working’ is closed to new replies.