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 pleaseIf 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.
Quote from Ignacio on May 7, 2020, 19:56Hi 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
Hi Pablo,
Quote from Pablo Borysenco on May 8, 2020, 12:06Hello Ignacio
I added this plugin to the adaptation queue
Hello Ignacio
I added this plugin to the adaptation queue
Quote from Ignacio on May 11, 2020, 22:04Hi 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!
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!
Quote from Pablo Borysenco on May 12, 2020, 12:39Hello
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
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
Quote from Ignacio on May 12, 2020, 19:19Hi 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:
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
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:
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
Quote from Pablo Borysenco on May 13, 2020, 11:47Hello 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?
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?
Quote from Ignacio on May 13, 2020, 12:15Hi 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.
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.
Quote from Pablo Borysenco on May 14, 2020, 11:23Hello
Ok! Thank you for info
Hello
Ok! Thank you for info
Quote from Ignacio on May 14, 2020, 14:49Thanks for looking into it!
Thanks for looking into it!
Quote from Pablo Borysenco on May 14, 2020, 19:35Hello
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
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
Quote from Ignacio on May 15, 2020, 01:22Hi 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.
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.
Quote from Pablo Borysenco on May 15, 2020, 11:40Hello
video - https://c2n.me/47wdE9R.mp4
Welcome;)
Hello
video - https://c2n.me/47wdE9R.mp4
Welcome;)
Quote from Ignacio on May 20, 2020, 06:18Hi 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);[/spoiler]
Thanks for everything.
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:
// 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.
Quote from Pablo Borysenco on May 20, 2020, 10:33Hello Ignacio
Thank you for cooperation!
I think you should contact the author of PPOM
Hello Ignacio
Thank you for cooperation!
I think you should contact the author of PPOM
Quote from Ignacio on May 21, 2020, 15:54Hi 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!
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!
Quote from Pablo Borysenco on May 21, 2020, 18:36Hello
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
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
Quote from Ignacio on May 26, 2020, 07:58Hi 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);
[/spoiler]
I appreciate your support so much! Glad it's a wrap!
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.
// 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!
Quote from Pablo Borysenco on May 26, 2020, 13:04Hello
Ok! Thank you for cooperation!
Hello
Ok! Thank you for cooperation!
