Support » Plugin: Product Fields, Addons and Price Calculator for WooCommerce » Compatibility with WOOCS – WooCommerce Currency Switcher

  • csabal

    (@csabal)


    Hi,

    I love your plugin very much, and I gonna donate you for sure.

    However there is a problem with the WOOCS – WooCommerce Currency Switcher. You can try on my website (it is still under construction), switch to EUR, then just add some custom text option on the bottom of the product page. You gonna see the problem.

    Thank you very much in advance!

    The page I need help with: [log in to see the link]

Viewing 15 replies - 1 through 15 (of 15 total)
  • Thread Starter csabal

    (@csabal)

    I figured out, IF I switch currency AFTER everything is in tha cart, everything ok.

    So I am so close … can you help me?

    csab

    Thread Starter csabal

    (@csabal)

    Soltuion would be simililar like this one: https://currency-switcher.com/wc-fields-factory?fbclid=IwAR1ND1pFuYrWCyeRsUXcAntUovZtHopnmL3H5lZ5ofN6qHQItFatmtBX_Kg#/woot-gallery-woof

    I just could not figure out how I can adapt this for you plugin actually.

    Plugin Author Krzysztof Piątkowski

    (@wckalkulator)

    Hello, unfortunately WOOCS plugin needs many hacks and workarounds to work with other plugins. Every price goes through that method https://github.com/piatkowski/wckalkulator/blob/master/src/FieldsetProduct.php#L788

    In that if statement add code like below:

    if (class_exists('WOOCS')) {
        global $WOOCS;
        $result['value'] = $WOOCS->woocs_exchange_value(floatval($result['value']));
    }
    Thread Starter csabal

    (@csabal)

    Hi
    Almost okay.

    Added the mentioned code, now it is changing the addon price to the right currency, and amount, however it is not added to the total product price (the sum would be 0). So, when I click add to cart, it is adding the product with 0 value to the cart….

    Maybe we should add something to the function.php?

    Thread Starter csabal

    (@csabal)

    I meant, the plugin shows only the addon price, not the total, and only this is added to the cart ( not the total price). I had try to move your mentioned code to other places, but no luck.
    We are so close to solve this issue, could you pls take a look?

    Plugin Author Krzysztof Piątkowski

    (@wckalkulator)

    @csabal please show me screen shots of your fieldset configuration and formula.

    Thread Starter csabal

    (@csabal)

    Thread Starter csabal

    (@csabal)

    Forgot to mention, that it is work well with the default currency (HUF) but if you switch to EUR it is not counting well. Your code is inserted to the fieldsetproduct.php as you mentioned before

    Plugin Author Krzysztof Piątkowski

    (@wckalkulator)

    I see now.

    First of all in FieldsetProduct.php code should look like

    $result = $parser->execute();
                    if (isset($result['value']) && $result['is_error'] === false) {
    	                if (class_exists('WOOCS')) {
    		                global $WOOCS;
    		                $result['value'] = $WOOCS->woocs_exchange_value(floatval($result['value']));
    	                }
                        $this->user_input['total_price'] = $result['value'] * $this->user_input["quantity"];
                    }
                    return $result;
    

    And then open ProductHelper.php and find every method which returns price (price, sale price, regular price) and apply woocs_exchange_value.

    I note that to add in the future releases, because you will lost these changes on update.

    Thread Starter csabal

    (@csabal)

    HI

    Thank you!

    How do I add the woocs_exchange_value to the ProductHelper.php ? What would be the exact method? Thx!

    Plugin Author Krzysztof Piątkowski

    (@wckalkulator)

    https://github.com/piatkowski/wckalkulator/blob/master/src/ProductHelper.php

    Line 100 and 111 should be wrapped in that additional WOOCS code

    Thread Starter csabal

    (@csabal)

    Hi, I added this, but did work (sorry I have very limited knowledge of coding)
    Could you pls send me an exact example? Thanks a lot in advance.

    public function sale_price()
        {
            return floatval($this->product->get_sale_price());
    		return floatval($this->product->woocs_exchange_value());
        }
    
        /**
         * Get regular price of the product or variation
         *
         * @return mixed
         * @since 1.0.0
         */
        public function regular_price()
        {
            return floatval($this->product->get_regular_price());
    		return floatval($this->product->woocs_exchange_value());
    
        }
    Plugin Author Krzysztof Piątkowski

    (@wckalkulator)

    Thread Starter csabal

    (@csabal)

    Thank you!!!

    Code added, browser cache flashed (there is no cache on the server side yet), but still when you change to EUR, it is not calculating in the right method.. 🙁

    csaba

    Thread Starter csabal

    (@csabal)

    Khm, maybe it is because this is a variation products! Not a single woo product!

    We may need add this to the variation part of the ProductHelper.php, I guess!

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘Compatibility with WOOCS – WooCommerce Currency Switcher’ is closed to new replies.