Public Ticket #3773426

Product Price returns 0 value in Offers

Closed
Comments
6 Tickets 3
Alexandros started the conversation 2 years ago on November 28, 2024 at 12:29pm

Hi there!

i am really happy with your plugin and especially with your support!

there is one issue that we found with the offers of the plugin.

First of all let me tell you that we use the B2C & B2B in the same woocommerce "mode" and there are products (variations to be specific) that we do not want to fill the retail price and we fill only the b2b price of the variation and we do not want to change that.

https://ibb.co/QmTmwLh

Now when we try to create from the administrator's panel an offer from b2b and we choose that variation, it returns 0 as the variation's price. 

Is it possible to return as a priority the b2b price?

Also, the price that is shown is WITH vat (+24%) so the price that we would like to return is the price without the vat (if it is possible of course). 


Looking forward for your answer

Alexandros

2,762
KingsPlugins replied 2 years ago on December 1, 2024 at 9:39pm

Hello Alexandros,

Glad to assist,

 

I understand that basically you'd like that to default to / prioritise the B2B price, if such a price exists? 

 

I tried writing a code snippet for that:

add_filter('b2bking_offer_price_default', function($regular_price, $product){

	// get group ID
	$group_id = 0;
	$groups = get_posts( array( 'post_type' => 'b2bking_group','post_status'=>'publish','numberposts' => -1) );
	foreach ($groups as $group){
		$group_id = $group->ID;
	}

	$sale_group_price = get_post_meta($product->get_id(),'b2bking_sale_product_price_group_'.$group_id, true);
	$price_default = $sale_group_price;

	if (empty($price_default)){
		$regular_group_price = get_post_meta($product->get_id(),'b2bking_regular_product_price_group_'.$group_id, true);
		$price_default = $regular_group_price;
	}

	if (empty($price_default)){
		$price_default = $regular_price;
	}

	if (!empty($price_default)){

		// remove 24%
		$price_default = round((floatval($price_default * 100) / 124), 2);
	}

	return $price_default;

}, 10, 2);

 

It should also remove 24% from the price.

 

This code can be added to functions.php or to any code snippets plugin.

 

This is what I see on my test site when I test with this code: https://www.loom.com/share/fd54a1efcfac46e98b11bd36a96fdcfe?sid=062b4672-14eb-4aad-a11c-fb6fe31e762c

 

Let me know if you have any issues with that,

Kind regards,

Stefan

6 Tickets 3
Alexandros replied 2 years ago on December 2, 2024 at 9:16am

Hello and thank you for your time and efford!

Your snippet  works well for simple products but in variations it does not work for all variations (for some reason)

our variation looks like this:

Cookies Christmas Time Bites (base product)

Cookies Christmas Time Bites - 1 unit (Retail price 4€ - B2B price null) <- the snippet works on that variation

Cookies Christmas Time Bites - Sample (Retail price null - B2B price 4€) <- the snippet works on that variation

Cookies Christmas Time Bites - 4 units (Retail price null - b2b price 9,92€) <- the snippet does not work on that variation

Cookies Christmas Time Bites - 6 units (Retail price null - b2b price 14,88€) <- the snippet does not work on that variation

2,762
KingsPlugins replied 2 years ago on December 9, 2024 at 5:09pm

I looked over that code again but I am not sure what it could be I'm afraid, I cannot seem to find the issue.

Would it be possible to share a temporary backend access to your site (or a staging clone site), so we can test directly? It would help so that I can then troubleshoot the issue throughout the code and run tests until we understand where the issue is.

Sign In