lundi 29 février 2016

Filter currency in wocoommerce and convert it from usd to inr for ccavenue

I am using ccavenue payment gateway on my wordpress site.
Plugin url is http://ift.tt/1neK8sI
But i am having one issue that my base currency is inr and ccavenue accepts payment in inr only, so when user switch the currency to usd then ccavenue is taking $40 as inr40.
I want to convert the currency before getting it to ccavenue page.
The code snippet for the same is.

 public function generate_ccavenue_form($order_id){

        global $woocommerce;
        $order = new WC_Order($order_id);
        $redirect_url = ($this -> redirect_page_id=="" || $this -> redirect_page_id==0)?get_site_url() . "/":get_permalink($this -> redirect_page_id);
      //For wooCoomerce 2.0

        $redirect_url = add_query_arg( 'wc-api', get_class( $this ), $redirect_url );
        $order_id = $order_id.'_'.date("ymds");
        $checksum = $this -> getCheckSum($this -> merchant_id, $order->order_total, $order_id, $redirect_url, $this -> working_key);


        $ccavenue_args = array(
            'Merchant_Id' => $this -> merchant_id,

            'Amount' => $order->order_total,
            'Order_Id' => $order_id,
            'Redirect_Url' => $redirect_url,
            'Checksum' => $checksum,
            'currency_code' => get_woocommerce_currency(),

            'billing_cust_name' => $order -> billing_first_name .' '. $order -> billing_last_name,
            'billing_cust_address' => $order -> billing_address_1,
            'billing_cust_country' => $order -> billing_country,
            'billing_cust_state' => $order -> billing_state,
            'billing_cust_city' => $order -> billing_city,
            'billing_zip' => $order -> shipping_postcode,
            'billing_cust_tel' => $order -> billing_phone,
            'billing_cust_email' => $order -> billing_email,
            'delivery_cust_name' => $order -> shipping_first_name .' '. $order -> shipping_last_name,
            'delivery_cust_address' => $order -> shipping_address_1,
            'delivery_cust_country' => $order -> shipping_country,
            'delivery_cust_state' => $order -> shipping_state,
            'delivery_cust_tel' => $order -> shipping_phone,
            'delivery_cust_notes' => '',
            'Merchant_Param' => '',
            'billing_zip_code' => $order -> billing_postcode,
            'delivery_cust_city' => $order -> shipping_city,
            'delivery_zip_code' => $order -> shipping_postcode
            );

        $ccavenue_args_array = array();
        foreach($ccavenue_args as $key => $value){
            $ccavenue_args_array[] = "<input type='hidden' name='$key' value='$value'/>";
        }

I think i have to add a filter hook for this in function.php. But i am not able to made and add a filter for this.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire