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

fetch the exchanged price to my mobile app

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.

hello

i am creating a mobile app using react native

i want to fetch the  exchanged price  as shown in my WordPress website

is there a library i can import it  to my app  or how could i fetch  that  exchanged  or at least fetch the exchange  price and multiply it to my products

or any other way pleas help...

 

Hello

You can get data about the current currency in this variable - woocs_current_currency

This stores an array. an  example:

{"name":"EUR","rate":0.91019999980926513671875,"symbol":"Euro","position":"left","is_etalon":0,"hide_cents":0,"hide_on_front":0,"rate_plus":"","decimals":2,"separators":"0","description":"","flag":"http:\/\/site.pro\/wp-content\/plugins\/woocommerce-currency-switcher\/img\/no_flag.png"}

could u tell me what is the endpoint for the plugin so i can access it through WordPress API

tocall the variable and fetch the data

wp-json/woocs/v3/currency  - to get data about all currencies

thank you

another question in my react native app  when i am creating orders  through  woo commerce API  the price is not  send in the Second currency  here is my checkout component code

const Checkout = ({ navigation, cartItems }) => {
  const [name, setName] = useState("");
  const [number, setNumber] = useState("");
  const [billingInfo, setBillingInfo] = useState({
    firstName:"",
    lastName:"",
    address:"",
    city:"",
    // Include additional billing fields as needed
  });
  const handleOrderSubmit = async () => {
    // Perform the submission logic here, e.g., create an order with WooCommerce
    // Example implementation using axios
    try {
      const currencyRate = await fetchCurrencyData();
      const lineItems = cartItems.map((item) => {
        const priceInCurrency = item.price * currencyRate; // Convert price to SYP
        return {
          product_id: item.id,
          quantity: item.quantity,
          price: priceInCurrency.toFixed(2), // Round the price to 2 decimal places
        };
      });
      // Prepare the order data
      const orderData = {
        billing: {
          first_name: billingInfo.firstName,
          last_name: billingInfo.lastName,
          address_1: billingInfo.address,
          city: billingInfo.city,
          // Include additional billing fields as needed
        },
        shipping: {
          first_name: billingInfo.firstName,
          last_name: billingInfo.lastName,
          address_1: billingInfo.address,
          city: billingInfo.city,
          // Include additional shipping fields as needed
        },
        line_items: lineItems,
        rate: currencyRate,
        currency:"SYP",
        shipping_lines: [
          {
            method_id:"local_pickup",
            method_title:"Local Pickup",
          },
        ],
        payment_method:"cod",
        payment_method_title:"Cash on Delivery",
        status:"processing",
      };
      const authString = `${apiKey}:${apiSecret}`;
      const encodedAuth = Base64.encode(authString); // Encode the authentication string
      const response = await axios.post(`${apiUrl}/orders`, orderData, {
        headers: {
          Authorization: `Basic ${encodedAuth}`, // Include the authentication header
        },
      });
      // Handle the response as needed
      console.log("Order created:", response.data);
      // Optionally, you can navigate to a success screen or perform any other action
      navigation.navigate("OrderSuccess");
    } catch (error) {
      // Handle the error
      console.error("Error creating order:", error);
    }
  };
};
 in this case  the order created IN the Second Currency SYP  but the price still in USD with the SYP symbol which mean it is not multiplied by the rate
    could u help me with that

Hello

I'm not sure I understood you. But if you received product data using the API. You should prepare this data to create an order (convert prices) For this you have all the values - Current currency and a list of all currencies with rates

I have a woocomerce  website that have products with price , I'm using  fox currency switcher to display the products with the another currency after multiply with the exchange rate  .

in my react native application  I'm using the woocomerce API to fetch the product with the prices ,i also fetched the currency rate and  multiply it with the price to display it as the second currency .

my question is when I'am creating order in my app through app woocomerc API  the order is created with the normal price , i need it to send with the second currency how

I think it's better for you to ask in woocommerce support

Each order has a currency field, assign the current currency to this field