class-categories.php
1 year ago
class-import-image.php
11 months ago
class-import-items.php
11 months ago
class-import-price-list.php
1 year ago
class-multi-currency.php
1 year ago
class-order-sync.php
11 months ago
class-product.php
1 year ago
class-users-contact.php
1 year ago
index.php
1 year ago
class-multi-currency.php
62 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * All Multi Currency related functions. |
| 5 | * |
| 6 | * @package WooZo Inventory |
| 7 | * @category Zoho Integration |
| 8 | * @author Roadmap Studios |
| 9 | * @link https://commercebird.com |
| 10 | */ |
| 11 | if ( ! defined( 'ABSPATH' ) ) { |
| 12 | exit; |
| 13 | } |
| 14 | |
| 15 | class CMBIRD_Multicurrency_Zoho { |
| 16 | |
| 17 | private $config; |
| 18 | public function __construct() { |
| 19 | |
| 20 | $config = array( |
| 21 | |
| 22 | 'MulticurrencyZI' => array( |
| 23 | 'OID' => get_option( 'cmbird_zoho_inventory_oid' ), |
| 24 | 'APIURL' => get_option( 'cmbird_zoho_inventory_url' ), |
| 25 | |
| 26 | ), |
| 27 | |
| 28 | ); |
| 29 | |
| 30 | $this->config = $config; |
| 31 | } |
| 32 | |
| 33 | public function zoho_currency_data( $user_currency, $userid ) { |
| 34 | |
| 35 | $zoho_inventory_oid = $this->config['MulticurrencyZI']['OID']; |
| 36 | $zoho_inventory_url = $this->config['MulticurrencyZI']['APIURL']; |
| 37 | |
| 38 | //execute curl |
| 39 | |
| 40 | $url = $zoho_inventory_url . 'inventory/v1/settings/currencies?organization_id=' . $zoho_inventory_oid; |
| 41 | |
| 42 | $execute_curl_call_handle = new CMBIRD_API_Handler_Zoho(); |
| 43 | $response = $execute_curl_call_handle->execute_curl_call_get( $url ); |
| 44 | |
| 45 | $code = $response->code; |
| 46 | $message = $response->message; |
| 47 | |
| 48 | if ( 0 == $code || '0' == $code ) { |
| 49 | |
| 50 | foreach ( $response->currencies as $key => $value ) { |
| 51 | if ( $value->currency_code == $user_currency ) { |
| 52 | update_user_meta( $userid, 'zi_currency_id', $value->currency_id ); |
| 53 | update_user_meta( $userid, 'zi_currency_code', $value->currency_code ); |
| 54 | } |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | $currency_id = intval( get_user_meta( $userid, 'zi_currency_id', true ) ); |
| 59 | return $currency_id; |
| 60 | } |
| 61 | } |
| 62 |