Add support for woocommerce-currency-switcher

parent 4bb9cc21
......@@ -184,7 +184,7 @@ class WooCommerce_Quick_Donation_Functions {
$amount = explode('|',$amount);
$c = get_woocommerce_currency_symbol();
foreach($amount as $amts){
$pre_amt[$amts] = $c.''.$amts;
$pre_amt[$amts] = $c.''.$this->get_price_in_current_currency(floatval($amts));
}
}
......@@ -354,6 +354,19 @@ class WooCommerce_Quick_Donation_Functions {
return $url;
}
public function get_current_currency() {
global $WOOCS;
if($this->currency_switcher) return $WOOCS->current_currency;
return get_woocommerce_currency();
}
public function get_price_in_current_currency($price) {
global $WOOCS;
if($this->currency_switcher) return apply_filters('woocs_exchange_value', $price);
return $price;
}
public function encryptor($action, $string) {
$output = false;
......
......@@ -114,8 +114,11 @@ class WooCommerce_Quick_Donation_Process extends WooCommerce_Quick_Donation {
$price_check = $this->check_min_max($projects,$donate_price);
if(!$price_check){return false;}
global $WOOCS;
$currencies = $WOOCS->get_currencies();
$value = $donate_price / $currencies[$WOOCS->current_currency]['rate'];
$woocommerce->session->donation_price = $donate_price;
$woocommerce->session->donation_price = $value;
$woocommerce->session->projects = $projects;
$woocommerce->session->is_donation_product = true;
......@@ -172,7 +175,7 @@ class WooCommerce_Quick_Donation_Process extends WooCommerce_Quick_Donation {
$price = intval($price);
if($min_required){
$min_required = intval($min_required);
$min_required = floatval(WC_QD()->f()->get_price_in_current_currency(floatval($min_required)));
if($price < $min_required){
$id = WC_QD_DB.'min_rda_msg';
$search_replace = array('{donation_amount}' => $price, '{min_amount}' => $min_required);
......@@ -184,7 +187,7 @@ class WooCommerce_Quick_Donation_Process extends WooCommerce_Quick_Donation {
if($max_required){
$max_required = intval($max_required);
$max_required = floatval(WC_QD()->f()->get_price_in_current_currency(floatval($max_required)));
if($price > $max_required){
$id = WC_QD_DB.'max_rda_msg';
$search_replace = array('{donation_amount}' => $price, '{max_amount}' => $max_required);
......
......@@ -11,5 +11,6 @@
type="<?php echo $field_type; ?>"
id="<?php echo $id; ?>"
name="<?php echo $name; ?>"
step="any"
class="<?php echo $class.' '.$attributes; ?>"
value="<?php echo $value; ?>" />
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment