PluginUs.Net - Business Tools for WooCommerce and WordPress

[realize your idea - make your dreams come true]

Support Forum

You need to log-in to create request (topic) to the support

WOOCS + PPOM + Woo Discount Rules

The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday. If you have problems with registration ask help on contact us page please
If you not got email within 24~36 business hours, firstly check your spam box, and if no any email from the support there - back to the forum and read answer here. DO NOT ANSWER ON EMAILS [noreply@pluginus.net] FROM THE FORUM!! Emails are just for your info, all answers should be published only here.
The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday.

Hi Pablo,

We interacted before on a support ticket on your site. While I managed to sort this situation among the compatibility with Woo Discount Rules, for which I thank you on how well everything is documented, I'm facing issues with PPOM Pro not showing the right discount prices.
I've noticed a few recent tickets of people requesting PPOM Pro (plugin) support on this fix and you mentioned it would be queued for adaptation about a year ago. Could you share a status on that solution or a workaround to get these variation prices through WOOCS? Woo Discount Rules has it's compatibility plugin installed and configured correctly, so I'm narrowing down the issue to PPOM. And since I haven't seen any hooks on their 'documentation' (non-existant), but seen you created adaptations on recent tickets, any insight you can share will be helpful (access info & purchase ID on private ticket data).
I'm reaching out as PPOM support has been extremely lacking on responding to this matter. Based on everything I've seen on the other developer's forums, this solution would help a lot of your plugin's users.
Thank you,
Ignacio Rusconi

Hello Ignacio

I added this plugin to the adaptation queue

Hi Pablo, I appreciate it, thank you!

I actually talked with the client and they are willing to extend their support through themeforest in the case that would help get a prompt solution as a way of payment, if that would help at all.

We literally got no support from the other developer after reaching out, so you are our last hope basically. I could try a patch if you have an idea on where I should tackle the issue for now. I'm writing a note on this on the private data module.

Thank you!

Hello

they are willing to extend their support through themeforest - Unfortunately, this does not affect development speed. You will have to wait in line

Best help us:  please describe in more detail all conflicts with this third-party plugin(in cart, shop page, single page, mini cart, checkout, orders,  ect.). You  can  use  screenshots

 

Hi Pablo,

Thank you for the promt response. Glad to report the situation, it actually only happens on the single product page. The default currency (whichever it might be) works with the expected behaviour. Whenever we are using a foreign currency (in our case USD & EUR), though, PPOM shows prices based on a matrix system on their own, but won't show the results WOOCS is successfully managing along with Woo Discount Rules (with it's own compatibility plugin). Therefore, the fix should be oriented (from my understanding) on a compatibility override of the output of the PPOM discount amount to take WOOCS' instead.

This happens regardless of the product variation affecting the price shown on top. It's just on every output. Screenshots attached:

single-product-novariation

single-product-variation1

single-product-variation2

cart_variation_off

cart_variation_on

Hope this helps, let me know if you would like to have a staging environment to test around. I'll be testing other solutions to replace the plugin in case it can be done, in which case I'll report a working alternative for the community.

Thanks man,

Ignacio

Hello Ignacio

Thanks for the description.

if you would like to have a staging environment to test around - I will do adaptation and testing on the site that you added to the private data.  OK?

Hi Pablo,

Thank you so much for the prompt response, you can find access to the staging environment in the private data. It's worth mentioning that I managed to get closer to a working solution last night within functions.php (submitted code and what to remove to fall back to last reported version), now showing product variations with the bad price on load, but as you change product variations on the front-end, it would show the right amount.

I've looked within your API on a way to force the original WOOCS prices there, but I couldn't find a way around it, nor on de-enabling the default variable (if they were no options selected, the default price would be ok until the fixed price loads - however that takes about 6 seconds to self-correct, horrible bug).  Here's an article that would complete the idea of what I had in mind.

What I could gather around PPOM is there are filters and hooks (lines 102~107 on plugins/ppom-pro/ppom.php) but as there's no documentation to go by I couln't think of anything else but an override.

Got thus far, hopefully these notes will provide ideas and directions.
Thank you.

Hello

Ok!  Thank  you for info

Thanks for looking into it!

Hello

My  test - https://c2n.me/47wdE9R  - PPOM does not affect the error (adaptation rejected)

Conflict here - plugins\woo-discount-rules-compatible\includes\compatibility.php - https://c2n.me/47wfNTl.png

 

Hi Pablo, thanks for the response, the first screenshot is missing (can you reupload please?). Thanks for reaching out. I tried many discount solutions, even compatible ones on your list, but the behaviour would repeat, that's why I thought it was a PPOM matter. I've got the second screenshot: I'll look into the compatibility issue, thanks for pinpointing me on the direction.

Hello

video - https://c2n.me/47wdE9R.mp4

Welcome;)

Hi Pablo, thank you so much for the feedback. After some more digging into it, the compatibility plugin doesn't fix compatibility with WOOCS on every scenario, but if Multiple Allowed is on, instead of the plugin, you can add this code in the functions.php file to make it work:

Spoiler

// Woo Discount Rules Compatibility with WOOCS (Display Conversion -> Higher Priority)

add_action( 'plugins_loaded', function(){
global $flycart_woo_discount_rules;
if(!empty($flycart_woo_discount_rules)){
remove_filter('woocommerce_get_price_html', array($flycart_woo_discount_rules->pricingRules, 'replaceVisiblePricesOptimized'), 1000, 3);
add_filter('woocommerce_get_price_html', array($flycart_woo_discount_rules->pricingRules, 'replaceVisiblePricesOptimized'), -1, 3);
}
});

// Woo Discount Rules Compatibility with WOOCS (for WOOCS w/ Multiple Enabled)

if(!function_exists('woo_discount_rules_discount_amount_before_apply_convert_price_to_current_currency')){
function woo_discount_rules_discount_amount_before_apply_convert_price_to_current_currency($price){
global $WOOCS;
if(isset($WOOCS)){
if (isset($WOOCS->default_currency) && isset($WOOCS->current_currency)){
if($WOOCS->default_currency != $WOOCS->current_currency && $WOOCS->is_multiple_allowed){
$currencies = $WOOCS->get_currencies();
$price = $price*$currencies[$WOOCS->current_currency]['rate'];
}
}
}
return $price;
}
}

add_filter('woo_discount_rules_discount_amount_before_apply', function ($discount, $set, $price, $product_page, $product){
if(isset($set['amount'])){
if(isset($set['amount']['product_discount_details'])){
if(isset($set['amount']['product_discount_details']['discount_type'])){
$discount_type = $set['amount']['product_discount_details']['discount_type'];
if($discount_type == 'price_discount'){
$discount = woo_discount_rules_discount_amount_before_apply_convert_price_to_current_currency($discount);
}
}
} else if(isset($set['amount']['price_discount'])){
$discount = woo_discount_rules_discount_amount_before_apply_convert_price_to_current_currency($set['amount']['price_discount']);
}
}
return $discount;
}, 10, 5);

add_filter('woo_discount_rules_table_content_discount_html', function($discount, $discount_type, $to_discount, $value){
if($discount_type == 'price_discount'){
$to_discount = woo_discount_rules_discount_amount_before_apply_convert_price_to_current_currency($to_discount);
$discount = wc_price($to_discount);
}
return $discount;
}, 10, 4);

//The bellow snippet should be used only if the discount value is not correct in cart even after the above snippet is added.(From v1.7.13)
// add_filter('woo_discount_rules_woocs_convert_price_based_on_currency', function($convert){
// global $WOOCS;
// if(isset($WOOCS)){
// if (isset($WOOCS->default_currency) && isset($WOOCS->current_currency)){
// if($WOOCS->default_currency != $WOOCS->current_currency){
// $convert = true;
// }
// }
// }
// return $convert;
// }, 10);

Thanks for everything.

Hello Ignacio

Thank you for  cooperation!

I think you should contact the author of PPOM

Hi Pablo,

We actually got PPOM out of the way, both in terms of support and in terms of it not being the issue generator. The problem relies only on Woo Discount Rules. Just so you know for future reference, their compatibility plugin doesn't do the trick when multiple is enabled (all fixed prices). For that I implemented the code snippet on the last pasted spoiler. However, now I'm finding the price is right when the product variation is selected, but the discounted price doesn't show neither on the cart nor the checkout (we get the regular price in there, while on non-default currencies).

I reached out Woo Discount Rules support to follow up. As the conflicting $tmp_val from the last testing phase does get the price right on the cart and checkout, I'm wondering if there's a way to implement that strictly to the cart/checkout product price, but no luck so far, all that is commented now on functions.php.

Right now all the functionality is coded in our functions.php, with no compatibility plugin. If you could take a look and pin point me on what could be generating this issue I'd be extremely helpful. I updated the port and password for the staging environment on the private data for this topic.

Thanks again!

Hello

Unfortunately I did not find the reason

But I think you should look here - plugins\woo-discount-rules\v1\includes\pricing-rules.php  function handleBOGODiscount

Hi Pablo, after getting a snippet from Woo Discount Rules, with some modifications of mine regarding woocs (the first statement) I've got it working. Reporting back in case any other future case or developer digging through the forums.

Spoiler

// Woo Discount Rules Compatibility with WOOCS (Product Page | for WOOCS w/ Multiple Enabled)

if(!function_exists('woo_discount_rules_discount_amount_before_apply_convert_price_to_current_currency')){
function woo_discount_rules_discount_amount_before_apply_convert_price_to_current_currency($price){
global $WOOCS;
if(isset($WOOCS)){
if (isset($WOOCS->default_currency) && isset($WOOCS->current_currency)){
if($WOOCS->default_currency != $WOOCS->current_currency && $WOOCS->is_multiple_allowed){
$currencies = $WOOCS->get_currencies();
$price = $price*$currencies[$WOOCS->current_currency]['rate'];
}
}
}
return $price;
}
}

function woocs_fixed_raw_woocommerce_price_method($tmp_val, $product_data, $price){
remove_filter('woocs_fixed_raw_woocommerce_price', 'woocs_fixed_raw_woocommerce_price_method', 10, 3);
$process = true;
if(isset($_REQUEST['action'])){
if($_REQUEST['action'] == 'woocs_get_products_price_html' || $_REQUEST['action'] == 'woocs_get_variation_products_price_html'){
$process = false;
}
}
if($process){
global $flycart_woo_discount_rules;
if(!empty($flycart_woo_discount_rules)){
global $product;
if(empty($product)){
$discount_price = $flycart_woo_discount_rules->pricingRules->getDiscountPriceOfProduct($product_data);
if($discount_price !== null){
$tmp_val = $discount_price;
}
}
}
}

add_filter('woocs_fixed_raw_woocommerce_price', 'woocs_fixed_raw_woocommerce_price_method', 10, 3);

return $tmp_val;
}
add_filter('woocs_fixed_raw_woocommerce_price', 'woocs_fixed_raw_woocommerce_price_method', 10, 3);

add_filter('woo_discount_rules_apply_rules_repeatedly', '__return_true');

if(!function_exists('woo_discount_rules_run_variation_strikeout_through_ajax_method')){
function woo_discount_rules_run_variation_strikeout_through_ajax_method($do_ajax){
return false;
}
}

add_filter('woo_discount_rules_run_variation_strikeout_through_ajax', 'woo_discount_rules_run_variation_strikeout_through_ajax_method');

if(!function_exists('woo_discount_rules_run_variation_strike_out_with_ajax_method')){
/**
* Run variaion strikeout through ajax
*
* @param string $do_with_out_ajax
* @param object $product
* @return boolean
* */
function woo_discount_rules_run_variation_strike_out_with_ajax_method($do_with_out_ajax, $product){
return false;
}
}

add_filter('woo_discount_rules_run_variation_strike_out_with_ajax', 'woo_discount_rules_run_variation_strike_out_with_ajax_method', 10, 2);

I appreciate your support so much! Glad it's a wrap!

Hello

Ok! Thank  you  for  cooperation!