Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors

Question / Issue

Hello, I would like to display the base price in WooCommerce. How does it work?

Answer / Solution

In order to display the base price for affiliate products, the following hook must be stored as a snippet. After that, WooCommerce will display the price from the affiliate product directly and also the base price (if any).

function cw_change_product_price_display( $price ) {
		$woo_id = get_the_ID();
		
		$productid = ATKPTools::get_post_setting( $woo_id, ATKP_PLUGIN_PREFIX . '_sourceproductid' );

		if ( $productid != '' && $productid != 0 ) {
			$product_list = atkp_product_collection::load( $productid );
			
			if($product_list != null && $product_list->get_main_product() != null)  {
				$formatter = new atkp_formatter( null, null );
				$product =$product_list->get_main_product();
				
				return $formatter->get_pricetext($product, __( '%s', ATKP_PLUGIN_PREFIX ), __( 'Price not available', ATKP_PLUGIN_PREFIX )). ' '. $formatter->get_basepricetext($product);
				
			}
		}
	
        return $price;
    }
    add_filter( 'woocommerce_get_price_html', 'cw_change_product_price_display' );
    add_filter( 'woocommerce_cart_item_price', 'cw_change_product_price_display' );
Updated: 6. September 2023
Still not using affiliate-toolkit?
Setup takes less than 5 minutes and you can start to import first products!
Learn more about the packagesDownload FREE Version
Still need help?
Submit Your Question
Please give us the details, our support team will get back to you.
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram