コード例 #1
0
 /**
  * Given all details converts currency amount
  *
  * @param $amt double
  *   The amount to convert.
  *
  * @param $to string
  *   The currency you wish to convert to.
  *
  * @param $from string
  *   The currency you are converting from.
  */
 function convert($amt = NULL, $to = '', $from = '')
 {
     $amount = urlencode(round($amt, 2));
     $from = urlencode($from);
     $to = urlencode($to);
     return wpsc_convert_currency($amount, $from, $to);
 }
コード例 #2
0
 private function convert($amt)
 {
     if ($this->is_currency_supported()) {
         return $amt;
     }
     return wpsc_convert_currency($amt, parent::get_currency_code(), $this->get_currency_code());
 }
コード例 #3
0
 public function get_gateway_data($from_currency = false, $to_currency = false)
 {
     if (!$this->exists()) {
         return array();
     }
     $subtotal = 0;
     $shipping = wpsc_convert_currency((double) $this->get('base_shipping'), $from_currency, $to_currency);
     $items = array();
     $this->gateway_data = array('amount' => wpsc_convert_currency($this->get('totalprice'), $from_currency, $to_currency), 'invoice' => $this->get('sessionid'), 'tax' => wpsc_convert_currency($this->get('wpec_taxes_total'), $from_currency, $to_currency));
     foreach ($this->cart_contents as $item) {
         $item_price = wpsc_convert_currency($item->price, $from_currency, $to_currency);
         $items[] = array('name' => $item->name, 'amount' => $item_price, 'tax' => wpsc_convert_currency($item->tax_charged, $from_currency, $to_currency), 'quantity' => $item->quantity);
         $subtotal += $item_price * $item->quantity;
         $shipping += wpsc_convert_currency($item->pnp, $from_currency, $to_currency);
     }
     $this->gateway_data['discount'] = wpsc_convert_currency((double) $this->get('discount_value'), $from_currency, $to_currency);
     $this->gateway_data['items'] = $items;
     $this->gateway_data['shipping'] = $shipping;
     $this->gateway_data['subtotal'] = $subtotal;
     if ($from_currency) {
         // adjust total amount in case there's slight decimal error
         $total = $subtotal + $shipping + $this->gateway_data['tax'] - $this->gateway_data['discount'];
         if ($this->gateway_data['amount'] != $total) {
             $this->gateway_data['amount'] = $total;
         }
     }
     $this->gateway_data = apply_filters('wpsc_purchase_log_gateway_data', $this->gateway_data, $this->get_data());
     return $this->gateway_data;
 }
コード例 #4
0
function wpsc_format_convert_price($amt, $from_currency = false, $to_currency = false)
{
    return wpsc_format_price(wpsc_convert_currency($amt, $from_currency, $to_currency), $to_currency);
}