/**
 * Gte woocommerce data for product
 *
 * @param $value
 * @param $data
 *
 * @return string
 */
function vc_gitem_template_attribute_woocommerce_product($value, $data)
{
    $label = '';
    /**
     * @var null|Wp_Post $post ;
     * @var string $data ;
     */
    extract(array_merge(array('post' => null, 'data' => ''), $data));
    require_once WC()->plugin_path() . '/includes/abstracts/abstract-wc-product.php';
    $product = new WC_Product($post);
    if (preg_match('/_labeled$/', $data)) {
        $data = preg_replace('/_labeled$/', '', $data);
        $label = apply_filters('vc_gitem_template_attribute_woocommerce_product_' . $data . '_label', Vc_Vendor_Woocommerce::getProductFieldLabel($data) . ': ');
    }
    $price_format = get_woocommerce_price_format();
    switch ($data) {
        case 'id':
            $value = (int) $product->is_type('variation') ? $product->get_variation_id() : $product->id;
            break;
        case 'sku':
            $value = $product->get_sku();
            break;
        case 'price':
            $value = sprintf($price_format, wc_format_decimal($product->get_price(), 2), get_woocommerce_currency());
            break;
        case 'regular_price':
            $value = sprintf($price_format, wc_format_decimal($product->get_regular_price(), 2), get_woocommerce_currency());
            break;
        case 'sale_price':
            $value = sprintf(get_woocommerce_price_format(), $product->get_sale_price() ? wc_format_decimal($product->get_sale_price(), 2) : '', get_woocommerce_currency());
            break;
        case 'price_html':
            $value = $product->get_price_html();
            break;
        case 'reviews_count':
            $value = count(get_comments(array('post_id' => $post->ID, 'approve' => 'approve')));
            break;
        case 'short_description':
            $value = apply_filters('woocommerce_short_description', $product->get_post_data()->post_excerpt);
            break;
        case 'dimensions':
            $units = get_option('woocommerce_dimension_unit');
            $value = $product->length . $units . 'x' . $product->width . $units . 'x' . $product->height . $units;
            break;
        case 'raiting_count':
            $value = $product->get_rating_count();
            break;
        case 'weight':
            $value = $product->get_weight() ? wc_format_decimal($product->get_weight(), 2) : '';
            break;
        case 'on_sale':
            $value = $product->is_on_sale() ? 'yes' : 'no';
            // @todo change
            break;
        default:
            $value = $product->{$data};
    }
    return strlen($value) > 0 ? $label . apply_filters('vc_gitem_template_attribute_woocommerce_product_' . $data . '_value', $value) : '';
}
 public function __construct()
 {
     global $woocommerce;
     $this->id = 'hygglig_checkout';
     $this->method_title = __('Hygglig', 'woocommerce');
     $this->method_description = __('Betala med Hygglig', 'woocommerce');
     $this->shop_country = get_option('woocommerce_default_country');
     // Check if woocommerce_default_country includes state as well. If it does, remove state
     if (strstr($this->shop_country, ':')) {
         $this->shop_country = current(explode(':', $this->shop_country));
     } else {
         $this->shop_country = $this->shop_country;
     }
     // Get current customers selected language if this is a multi lanuage site
     $iso_code = explode('_', get_locale());
     $this->shop_language = strtoupper($iso_code[0]);
     // Country ISO code (SE)
     //Switch built to allow for addition of more countries
     switch ($this->shop_language) {
         case 'SV':
             $this->shop_language = 'SE';
             break;
     }
     // Currency
     $this->selected_currency = get_woocommerce_currency();
     // Apply filters to shop_country
     $this->shop_country = apply_filters('hygglig_shop_country', $this->shop_country);
 }
Example #3
0
 public function calculate_shipping($package = array())
 {
     $request = array('recipient' => array('address1' => $package['destination']['address'], 'address2' => $package['destination']['address_2'], 'city' => $package['destination']['city'], 'state_code' => $package['destination']['state'], 'country_code' => $package['destination']['country'], 'zip' => $package['destination']['postcode']), 'items' => array(), 'currency' => get_woocommerce_currency());
     foreach ($package['contents'] as $item) {
         if (!empty($item['data']) && ($item['data']->is_virtual() || $item['data']->is_downloadable())) {
             continue;
         }
         $request['items'][] = array('external_variant_id' => $item['variation_id'] ? $item['variation_id'] : $item['product_id'], 'quantity' => $item['quantity']);
     }
     if (!$request['items']) {
         return false;
     }
     try {
         $client = Printful_Integration::instance()->get_client();
     } catch (PrintfulException $e) {
         $this->set_error($e);
         return false;
     }
     try {
         $response = $client->post('shipping/rates', $request, array('expedited' => true));
         foreach ($response as $rate) {
             $rateData = array('id' => $this->id . '_' . $rate['id'], 'label' => $rate['name'], 'cost' => $rate['rate'], 'taxes' => false, 'calc_tax' => 'per_order');
             $this->add_rate($rateData);
         }
     } catch (PrintfulException $e) {
         $this->set_error($e);
         return false;
     }
 }
 /**
  * get_currency_countries.
  *
  * @version 2.3.9
  */
 function get_currency_countries($limit_currencies = '')
 {
     $country_currency = wcj_get_country_currency();
     if ('' != $limit_currencies) {
         $default_currency = get_woocommerce_currency();
         if ('paypal_only' === $limit_currencies || 'paypal_and_yahoo_exchange_rates_only' === $limit_currencies) {
             $paypal_supported_currencies = wcj_get_paypal_supported_currencies();
         }
         if ('yahoo_exchange_rates_only' === $limit_currencies || 'paypal_and_yahoo_exchange_rates_only' === $limit_currencies) {
             $yahoo_exchange_rates_supported_currencies = wcj_get_yahoo_exchange_rates_supported_currency();
         }
     }
     $currencies = array();
     foreach ($country_currency as $country => $currency) {
         if ('paypal_only' === $limit_currencies) {
             if (!isset($paypal_supported_currencies[$currency])) {
                 $currency = $default_currency;
             }
         } elseif ('yahoo_exchange_rates_only' === $limit_currencies) {
             if (!isset($yahoo_exchange_rates_supported_currencies[$currency])) {
                 $currency = $default_currency;
             }
         } elseif ('paypal_and_yahoo_exchange_rates_only' === $limit_currencies) {
             if (!isset($paypal_supported_currencies[$currency]) || !isset($yahoo_exchange_rates_supported_currencies[$currency])) {
                 $currency = $default_currency;
             }
         }
         $currencies[$currency][] = $country;
     }
     return $currencies;
 }
 /**
  * Process the subscription payment and return the result
  *
  * @access      public
  * @param       int $amount
  * @return      array
  */
 public function process_subscription_payment($amount = 0)
 {
     global $s4wc;
     // Can't send to stripe without a value, assume it's good to go.
     if ($amount === 0) {
         return true;
     }
     // Get customer id
     $customer = get_user_meta($this->order->user_id, $s4wc->settings['stripe_db_location'], true);
     // Allow options to be set without modifying sensitive data like amount, currency, etc.
     $stripe_charge_data = apply_filters('s4wc_subscription_charge_data', array(), $this->order);
     // Set up basics for charging
     $stripe_charge_data['amount'] = $amount * 100;
     // amount in cents
     $stripe_charge_data['currency'] = strtolower(get_woocommerce_currency());
     $stripe_charge_data['customer'] = $customer['customer_id'];
     $stripe_charge_data['card'] = $customer['default_card'];
     $stripe_charge_data['description'] = $this->get_charge_description('subscription');
     $stripe_charge_data['expand[]'] = 'balance_transaction';
     $charge = S4WC_API::create_charge($stripe_charge_data);
     if (isset($charge->id)) {
         $this->order->add_order_note(sprintf(__('Subscription paid (%s)', 'stripe-for-woocommerce'), $charge->id));
         return $charge;
     }
     return false;
 }
 public function is_valid_for_use()
 {
     if (!in_array(get_woocommerce_currency(), apply_filters('wc_korea_pack_supported_currencies_bank', $this->supported_currencies))) {
         return false;
     }
     return true;
 }
Example #7
0
/**
 * Displays the Installments on the product page.
 *
 * @return string Price in 3 installments.
 */
function cs_product_parceled_single()
{
    $product = get_product();
    ?>
    <div itemprop="offers" itemscope itemtype="http://schema.org/Offer">

        <p style="margin: 0;" itemprop="price" class="price">
            <?php 
    echo $product->get_price_html();
    ?>
        </p>
        <p>
            <span style="color: #666; font-size: 100%" class="price"><?php 
    _e('ou at&eacute; 3x de');
    ?>
 <?php 
    echo cs_product_parceled();
    ?>
</span>
        </p>

        <meta itemprop="priceCurrency" content="<?php 
    echo get_woocommerce_currency();
    ?>
" />
        <link itemprop="availability" href="http://schema.org/<?php 
    echo $product->is_in_stock() ? 'InStock' : 'OutOfStock';
    ?>
" />
    </div>
<?php 
}
        /**
         * Generate razorpay button link
         **/
        public function generate_razorpay_form($order_id)
        {
            global $woocommerce;
            $order = new WC_Order($order_id);
            $redirect_url = get_site_url() . '/?wc-api' . "=" . get_class($this);
            $productinfo = "Order {$order_id}";
            $razorpay_args = array('key' => $this->key_id, 'name' => get_bloginfo('name'), 'amount' => $order->order_total * 100, 'currency' => get_woocommerce_currency(), 'description' => $productinfo, 'prefill' => array('name' => $order->billing_first_name . " " . $order->billing_last_name, 'email' => $order->billing_email, 'contact' => $order->billing_phone), 'notes' => array('woocommerce_order_id' => $order_id));
            $json = json_encode($razorpay_args);
            $html = <<<EOT
<script src="{$this->liveurl}"></script>
<script>
    var data = {$json};
</script>
<form name='razorpayform' action="{$redirect_url}" method="POST">
    <input type="hidden" name="merchant_order_id" value="{$order_id}">
    <input type="hidden" name="razorpay_payment_id" id="razorpay_payment_id">
</form>
<script>
    data.backdropClose = false;
    data.handler = function(payment){
      document.getElementById('razorpay_payment_id').value = 
        payment.razorpay_payment_id;
      document.razorpayform.submit();
    };
    var razorpayCheckout = new Razorpay(data);
    razorpayCheckout.open();
</script>
<p>
<button id="btn-razorpay" onclick="razorpayCheckout.open();">Pay Now</button>
<button onclick="document.razorpayform.submit()">Cancel</button>
</p>

EOT;
            return $html;
        }
 /**
  * Get the accounting format from user settings
  * POS uses a plugin to format currency: http://josscrowcroft.github.io/accounting.js/
  *
  * @return array $settings
  */
 private function accounting()
 {
     $decimal = get_option('woocommerce_price_decimal_sep');
     $thousand = get_option('woocommerce_price_thousand_sep');
     $precision = get_option('woocommerce_price_num_decimals');
     return array('currency' => array('decimal' => $decimal, 'format' => $this->currency_format(), 'precision' => $precision, 'symbol' => get_woocommerce_currency_symbol(get_woocommerce_currency()), 'thousand' => $thousand), 'number' => array('decimal' => $decimal, 'precision' => $precision, 'thousand' => $thousand));
 }
 /**
  * Pay method, used to process payment requests
  *
  * @param $payment_detail  array  Array of parameters for the single requests
  * Excepts at least the following parameters for each payment to process
  * [
  *     paypal_email => string (Paypal email of the receiver)
  *     amount => float (Amount to pay to user)
  *     request_id => int (Unique id of the request paid)
  * ]
  *
  * @return array An array holding the status of the operation; it should have at least a boolean status, a verbose status and an array of messages
  * [
  *     status => bool (status of the operation)
  *     verbose_status => string (one between PAYMENT_STATUS_OK and PAYMENT_STATUS_FAIL)
  *     messages => string|array (one or more message describing operation status)
  * ]
  * @since 1.0
  * @author Antonio La Rocca <*****@*****.**>
  */
 public function pay($payment_detail)
 {
     // include required libraries
     require_once dirname(dirname(__FILE__)) . '/third-party/PayPal/PayPal.php';
     // retrieve saved options from panel
     $stored_options = $this->get_gateway_options();
     $currency = get_woocommerce_currency();
     if (empty($stored_options['api_username']) || empty($stored_options['api_password']) || empty($stored_options['api_signature'])) {
         return array('status' => false, 'verbose_status' => YITH_Vendors_Gateway::PAYMENT_STATUS_FAIL, 'messages' => __('Missing required parameters for PayPal configuration', 'yith_wc_product_vendors'));
     }
     $PayPalConfig = array('Sandbox' => !($stored_options['sandbox'] == 'no'), 'APIUsername' => $stored_options['api_username'], 'APIPassword' => $stored_options['api_password'], 'APISignature' => $stored_options['api_signature'], 'PrintHeaders' => true, 'LogResults' => false);
     $PayPal = new PayPal($PayPalConfig);
     // Prepare request arrays
     $MPFields = array('emailsubject' => $stored_options['payment_mail_subject'], 'currencycode' => $currency, 'receivertype' => 'EmailAddress');
     $MPItems = array();
     foreach ($payment_detail as $payment) {
         $MPItems[] = array('l_email' => $payment['paypal_email'], 'l_amt' => $payment['amount'], 'l_uniqueid' => $payment['request_id']);
     }
     $PayPalRequestData = array('MPFields' => $MPFields, 'MPItems' => $MPItems);
     $PayPalResult = $PayPal->MassPay($PayPalRequestData);
     $errors = array();
     if ($PayPalResult['ACK'] == self::PAYMENT_STATUS_FAIL) {
         foreach ($PayPalResult['ERRORS'] as $error) {
             $errors[] = $error['L_LONGMESSAGE'];
         }
     }
     return array('status' => $PayPalResult['ACK'] == self::PAYMENT_STATUS_OK, 'verbose_status' => $PayPalResult['ACK'], 'messages' => $PayPalResult['ACK'] == self::PAYMENT_STATUS_FAIL ? implode("\n", $errors) : __('Payment sent', 'yith_wc_product_vendors'));
 }
    public function admin_options()
    {
        // Check curentcy.
        if (get_woocommerce_currency() != "DKK") {
            echo '<div class="error">
				<p>' . sprintf(__('Send24 requires that the <a href="%s">currency</a> is set to Danish Krone (DKK).', 'woocommerce-shipping-usps'), admin_url('admin.php?page=wc-settings&tab=general')) . '</p>
			</div>';
        }
        // Save/Update key.
        if (empty($this->send24_settings)) {
            add_option('send24_settings', $this->settings);
        } else {
            update_option('send24_settings', $this->settings);
        }
        // Check keys and zip user.
        if ($_POST) {
            $this->check_key_and_zip($_POST['woocommerce_send24_shipping_c_key'], $_POST['woocommerce_send24_shipping_c_secret'], $_POST['woocommerce_send24_shipping_zip']);
        } else {
            $this->check_key_and_zip($this->send24_settings['c_key'], $this->send24_settings['c_secret'], $this->send24_settings['zip']);
        }
        // Show settings
        parent::admin_options();
        // Check and show service.
        if ($_POST) {
            if (!empty($_POST['woocommerce_send24_shipping_enabled_services'])) {
                echo $this->generate_services_html($_POST['woocommerce_send24_shipping_enabled_services']);
            } else {
                echo $this->generate_services_html('no');
            }
        } else {
            echo $this->generate_services_html($this->send24_settings['enabled_services']);
        }
    }
 public function makePayload(\FS\Components\Order\ShoppingOrder $order)
 {
     $payload = array();
     $settings = $this->getApplicationContext()->getComponent('\\FS\\Components\\Settings');
     $shipment = $order->getFlagShipRaw();
     $service = $order->getShippingService();
     // shipment created
     if ($shipment) {
         $payload['type'] = 'created';
         $payload['shipment'] = $shipment;
         return $payload;
     }
     // quoted but no shipment created
     if (!$shipment && $service['provider'] == $settings['FLAGSHIP_SHIPPING_PLUGIN_ID']) {
         $payload['type'] = 'create';
         $payload['service'] = $service;
         $payload['cod'] = array('currency' => strtoupper(get_woocommerce_currency()));
     }
     // possibly not quoted with FS
     if (!isset($payload['type'])) {
         $payload['type'] = 'unavailable';
     }
     // requotes
     if ($requoteRates = $order->getAttribute('flagship_shipping_requote_rates')) {
         $payload['requote_rates'] = $requoteRates;
     }
     return $payload;
 }
Example #13
0
 function init_form_fields()
 {
     $this->form_fields = array('enabled' => array('title' => __('Activar/Desactivar', 'meowallet'), 'label' => __('Activar o MEO Wallet', 'meowallet'), 'type' => 'checkbox', 'description' => __('Activar o MEO Wallet', 'meowallet'), 'default' => 'yes'), 'title' => array('title' => __('Titulo', 'meowallet'), 'type' => 'text', 'description' => __('Dá um titulo à forma de pagamento para ser visto durante o pagamento', 'meowallet'), 'default' => __('MEO Wallet', 'meowallet')), 'description' => array('title' => __('Descrição', 'meowallet'), 'type' => 'textarea', 'description' => __('Oferece uma Descrição da forma de pagamento por MEO Wallet aos seus clientes para ser vista durante o processo de pagamento', 'meowallet'), 'default' => __('Pagar com MEO Wallet - MEO Wallet, Multibanco, Cartão de Crédito/Débito', 'meowallet')), 'apikey_live' => array('title' => __('Chave API', 'meowallet'), 'type' => 'text', 'description' => __('Introduza a sua Chave API do MEO Wallet . Não é a mesma que a Chave API do MEO Wallet-Sandbox. <br />Para obter a sua Chave API, clique <a target="_blank" href="https://www.sandbox.meowallet.pt/login/">aqui</a>', 'meowallet'), 'default' => '', 'class' => 'production_settings sensitive'), 'apikey_sandbox' => array('title' => __('Chave API Sandbox', 'meowallet'), 'type' => 'text', 'description' => __('Introduza a sua Chave API de testes do MEO Wallet. <br />Para obter a sua Chave API, clique <a target="_blank" href="https://www.wallet.pt/login/">aqui</a>', 'meowallet'), 'default' => '', 'class' => 'sandbox_settings sensitive'), 'environment' => array('title' => __('Escolher Ambiente de Trabalho', 'meowallet'), 'type' => 'select', 'label' => __('Activar o MEO Wallet em modo de tests!', 'meowallet'), 'description' => __('Escolha o seu Ambiente de Trabalho entre Teste e Produção.', 'meowallet'), 'default' => 'sandbox', 'options' => array('sandbox' => __('Teste', 'meowallet'), 'production' => __('Produção', 'meowallet'))));
     if (get_woocommerce_currency() != 'EUR') {
         $this->form_fields['ex_to_euro'] = array('title' => __("Taxa de Cambio para Euro", 'meowallet'), 'type' => 'text', 'description' => 'Taxa de Cambio para Euro', 'default' => '1');
     }
 }
 /**
  * Check if this gateway is enabled and available in the user's country.
  *
  * @return bool
  */
 public function is_valid_for_use()
 {
     if (!in_array(get_woocommerce_currency(), array('BRL'))) {
         return false;
     }
     return true;
 }
 /**
  * Display an assortment of notices to administrators to encourage them to get PayPal setup right.
  *
  * @since 2.0
  */
 public static function maybe_show_admin_notices()
 {
     self::maybe_disable_invalid_profile_notice();
     self::maybe_update_credentials_error_flag();
     if (!in_array(get_woocommerce_currency(), apply_filters('woocommerce_paypal_supported_currencies', array('AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB')))) {
         $valid_for_use = false;
     } else {
         $valid_for_use = true;
     }
     $payment_gateway_tab_url = admin_url('admin.php?page=wc-settings&tab=checkout&section=wc_gateway_paypal');
     $notices = array();
     if ($valid_for_use && 'yes' == WCS_PayPal::get_option('enabled') && !has_action('admin_notices', 'WC_Subscriptions_Admin::admin_installed_notice') && current_user_can('manage_options')) {
         if (!WCS_PayPal::are_credentials_set()) {
             $notices[] = array('type' => 'warning', 'text' => sprintf(esc_html__('PayPal is inactive for subscription transactions. Please %1$sset up the PayPal IPN%2$s and %3$senter your API credentials%4$s to enable PayPal for Subscriptions.', 'woocommerce-subscriptions'), '<a href="http://docs.woothemes.com/document/subscriptions/store-manager-guide/#section-4" target="_blank">', '</a>', '<a href="' . esc_url($payment_gateway_tab_url) . '">', '</a>'));
         } elseif ('woocommerce_page_wc-settings' === get_current_screen()->base && isset($_GET['tab']) && in_array($_GET['tab'], array('subscriptions', 'checkout')) && !WCS_PayPal::are_reference_transactions_enabled()) {
             $notices[] = array('type' => 'warning', 'text' => sprintf(esc_html__('%1$sPayPal Reference Transactions are not enabled on your account%2$s, some subscription management features are not enabled. Please contact PayPal and request they %3$senable PayPal Reference Transactions%4$s on your account. %5$sCheck PayPal Account%6$s  %7$sLearn more %8$s', 'woocommerce-subscriptions'), '<strong>', '</strong>', '<a href="http://docs.woothemes.com/document/subscriptions/store-manager-guide/#section-4" target="_blank">', '</a>', '</p><p><a class="button" href="' . esc_url(wp_nonce_url(add_query_arg('wcs_paypal', 'check_reference_transaction_support'), __CLASS__)) . '">', '</a>', '<a class="button button-primary" href="http://docs.woothemes.com/document/subscriptions/store-manager-guide/#section-4" target="_blank">', '&raquo;</a>'));
         }
         if (isset($_GET['wcs_paypal']) && 'rt_enabled' === $_GET['wcs_paypal']) {
             $notices[] = array('type' => 'confirmation', 'text' => sprintf(esc_html__('%1$sPayPal Reference Transactions are enabled on your account%2$s. All subscription management features are now enabled. Happy selling!', 'woocommerce-subscriptions'), '<strong>', '</strong>'));
         }
         if (false !== get_option('wcs_paypal_credentials_error')) {
             $notices[] = array('type' => 'error', 'text' => sprintf(esc_html__('There is a problem with PayPal. Your API credentials may be incorrect. Please update your %1$sAPI credentials%2$s. %3$sLearn more%4$s.', 'woocommerce-subscriptions'), '<a href="' . esc_url($payment_gateway_tab_url) . '">', '</a>', '<a href="https://support.woothemes.com/hc/en-us/articles/202882473#paypal-credentials" target="_blank">', '</a>'));
         }
         if ('yes' == get_option('wcs_paypal_invalid_profile_id')) {
             $notices[] = array('type' => 'error', 'text' => sprintf(esc_html__('There is a problem with PayPal. Your PayPal account is issuing out-of-date subscription IDs. %1$sLearn more%2$s. %3$sDismiss%4$s.', 'woocommerce-subscriptions'), '<a href="https://support.woothemes.com/hc/en-us/articles/202882473#old-paypal-account" target="_blank">', '</a>', '<a href="' . esc_url(add_query_arg('wcs_disable_paypal_invalid_profile_id_notice', 'true')) . '">', '</a>'));
         }
     }
     if (!empty($notices)) {
         include_once dirname(__FILE__) . '/../templates/admin-notices.php';
     }
 }
 /**
  * Sets up the express checkout transaction
  *
  * @link https://developer.paypal.com/docs/classic/express-checkout/integration-guide/ECGettingStarted/#id084RN060BPF
  * @link https://developer.paypal.com/webapps/developer/docs/classic/api/merchant/SetExpressCheckout_API_Operation_NVP/
  *
  * @param array $args {
  *     @type string 'currency'              (Optional) A 3-character currency code (default is store's currency).
  *     @type string 'billing_type'          (Optional) Type of billing agreement for reference transactions. You must have permission from PayPal to use this field. This field must be set to one of the following values: MerchantInitiatedBilling - PayPal creates a billing agreement for each transaction associated with buyer. You must specify version 54.0 or higher to use this option; MerchantInitiatedBillingSingleAgreement - PayPal creates a single billing agreement for all transactions associated with buyer. Use this value unless you need per-transaction billing agreements. You must specify version 58.0 or higher to use this option.
  *     @type string 'billing_description'   (Optional) Description of goods or services associated with the billing agreement. This field is required for each recurring payment billing agreement if using MerchantInitiatedBilling as the billing type, that means you can use a different agreement for each subscription/order. PayPal recommends that the description contain a brief summary of the billing agreement terms and conditions (but this only makes sense when the billing type is MerchantInitiatedBilling, otherwise the terms will be incorrectly displayed for all agreements). For example, buyer is billed at "9.99 per month for 2 years".
  *     @type string 'maximum_amount'        (Optional) The expected maximum total amount of the complete order and future payments, including shipping cost and tax charges. If you pass the expected average transaction amount (default 25.00). PayPal uses this value to validate the buyer's funding source.
  *     @type string 'no_shipping'           (Optional) Determines where or not PayPal displays shipping address fields on the PayPal pages. For digital goods, this field is required, and you must set it to 1. It is one of the following values: 0 – PayPal displays the shipping address on the PayPal pages; 1 – PayPal does not display shipping address fields whatsoever (default); 2 – If you do not pass the shipping address, PayPal obtains it from the buyer's account profile.
  *     @type string 'page_style'            (Optional) Name of the Custom Payment Page Style for payment pages associated with this button or link. It corresponds to the HTML variable page_style for customizing payment pages. It is the same name as the Page Style Name you chose to add or edit the page style in your PayPal Account profile.
  *     @type string 'brand_name'            (Optional) A label that overrides the business name in the PayPal account on the PayPal hosted checkout pages. Default: store name.
  *     @type string 'landing_page'          (Optional) Type of PayPal page to display. It is one of the following values: 'login' – PayPal account login (default); 'Billing' – Non-PayPal account.
  *     @type string 'payment_action'        (Optional) How you want to obtain payment. If the transaction does not include a one-time purchase, this field is ignored. Default 'Sale' – This is a final sale for which you are requesting payment (default). Alternative: 'Authorization' – This payment is a basic authorization subject to settlement with PayPal Authorization and Capture. You cannot set this field to Sale in SetExpressCheckout request and then change the value to Authorization or Order in the DoExpressCheckoutPayment request. If you set the field to Authorization or Order in SetExpressCheckout, you may set the field to Sale.
  *     @type string 'return_url'            (Required) URL to which the buyer's browser is returned after choosing to pay with PayPal.
  *     @type string 'cancel_url'            (Required) URL to which the buyer is returned if the buyer does not approve the use of PayPal to pay you.
  *     @type string 'custom'                (Optional) A free-form field for up to 256 single-byte alphanumeric characters
  * }
  * @since 2.0
  */
 public function set_express_checkout($args)
 {
     $default_description = sprintf(_x('Orders with %s', 'data sent to paypal', 'woocommerce-subscriptions'), get_bloginfo('name'));
     $defaults = array('currency' => get_woocommerce_currency(), 'billing_type' => apply_filters('woocommerce_subscriptions_paypal_billing_agreement_type', 'MerchantInitiatedBillingSingleAgreement', $args), 'billing_description' => html_entity_decode(apply_filters('woocommerce_subscriptions_paypal_billing_agreement_description', $default_description, $args), ENT_NOQUOTES, 'UTF-8'), 'maximum_amount' => null, 'no_shipping' => 1, 'page_style' => null, 'brand_name' => html_entity_decode(get_bloginfo('name'), ENT_NOQUOTES, 'UTF-8'), 'landing_page' => 'login', 'payment_action' => 'Sale', 'custom' => '');
     $args = wp_parse_args($args, $defaults);
     $this->set_method('SetExpressCheckout');
     $this->add_parameters(array('PAYMENTREQUEST_0_AMT' => 0, 'PAYMENTREQUEST_0_ITEMAMT' => 0, 'PAYMENTREQUEST_0_SHIPPINGAMT' => 0, 'PAYMENTREQUEST_0_TAXAMT' => 0, 'PAYMENTREQUEST_0_CURRENCYCODE' => $args['currency'], 'PAYMENTREQUEST_0_CUSTOM' => $args['custom'], 'L_BILLINGTYPE0' => $args['billing_type'], 'L_BILLINGAGREEMENTDESCRIPTION0' => wcs_get_paypal_item_name($args['billing_description']), 'L_BILLINGAGREEMENTCUSTOM0' => $args['custom'], 'RETURNURL' => $args['return_url'], 'CANCELURL' => $args['cancel_url'], 'PAGESTYLE' => $args['page_style'], 'BRANDNAME' => $args['brand_name'], 'LANDINGPAGE' => 'login' == $args['landing_page'] ? 'Login' : 'Billing', 'NOSHIPPING' => $args['no_shipping'], 'MAXAMT' => $args['maximum_amount'], 'PAYMENTREQUEST_0_PAYMENTACTION' => $args['payment_action']));
 }
 function check_currency()
 {
     $current_currency = get_woocommerce_currency();
     if ($current_currency != 'IDR') {
         $exit_msg = 'Plugin MyOngkir Shipping must use IDR currency.';
         exit($exit_msg);
     }
 }
 public function is_valid_for_use()
 {
     if (!in_array(get_woocommerce_currency(), array('NGN'))) {
         $this->msg = 'Voguepay doesn\'t support your store currency, set it to Nigerian Naira &#8358; <a href="' . get_bloginfo('wpurl') . '/wp-admin/admin.php?page=wc-settings&tab=general">here</a>';
         return false;
     }
     return true;
 }
 function wcml_convert_price($formatted, $unformatted)
 {
     if (!is_admin()) {
         $currency = apply_filters('wcml_price_currency', get_woocommerce_currency());
         $formatted = strip_tags(wc_price(apply_filters('wcml_raw_price_amount', $unformatted), array('currency' => $currency)));
     }
     return $formatted;
 }
 function run()
 {
     global $woocommerce_wpml;
     if (isset($_POST['general_options']) && check_admin_referer('general_options', 'general_options_nonce') && wp_verify_nonce($_POST['wcml_nonce'], 'general_options')) {
         $woocommerce_wpml->settings['enable_multi_currency'] = $_POST['multi_currency'];
         $woocommerce_wpml->update_settings();
     }
     if (isset($_POST['currency_switcher_options']) && check_admin_referer('currency_switcher_options', 'currency_switcher_options_nonce') && wp_verify_nonce($_POST['wcml_nonce'], 'general_options')) {
         if (isset($_POST['currency_switcher_style'])) {
             $woocommerce_wpml->settings['currency_switcher_style'] = $_POST['currency_switcher_style'];
         }
         if (isset($_POST['wcml_curr_sel_orientation'])) {
             $woocommerce_wpml->settings['wcml_curr_sel_orientation'] = $_POST['wcml_curr_sel_orientation'];
         }
         if (isset($_POST['wcml_curr_template'])) {
             $woocommerce_wpml->settings['wcml_curr_template'] = $_POST['wcml_curr_template'];
         }
         $woocommerce_wpml->update_settings();
     }
     if (isset($_POST['wcml_update_languages_currencies']) && isset($_POST['currency_for']) && wp_verify_nonce($_POST['wcml_nonce'], 'wcml_update_languages_currencies')) {
         global $wpdb;
         $currencies = $_POST['currency_for'];
         foreach ($currencies as $key => $language_currency) {
             $exist_currency = $wpdb->get_var($wpdb->prepare("SELECT currency_id FROM " . $wpdb->prefix . "icl_languages_currencies WHERE language_code = %s", $key));
             if ($language_currency != get_woocommerce_currency()) {
                 if (!$exist_currency) {
                     $wpdb->insert($wpdb->prefix . 'icl_languages_currencies', array('currency_id' => $language_currency, 'language_code' => $key));
                 } else {
                     $wpdb->update($wpdb->prefix . 'icl_languages_currencies', array('currency_id' => $language_currency), array('language_code' => $key));
                     wp_safe_redirect(admin_url('admin.php?page=wpml-wcml'));
                 }
             } elseif ($exist_currency) {
                 $wpdb->query("DELETE FROM " . $wpdb->prefix . "icl_languages_currencies WHERE language_code = '{$key}'");
             }
         }
     }
     if (isset($_POST['wcml_file_path_options_table']) && wp_verify_nonce($_POST['wcml_nonce'], 'wcml_file_path_options_table')) {
         global $sitepress, $sitepress_settings;
         $woocommerce_wpml->settings['file_path_sync'] = $_POST['wcml_file_path_sync'];
         $woocommerce_wpml->update_settings();
         $new_value = $_POST['wcml_file_path_sync'] == 0 ? 2 : $_POST['wcml_file_path_sync'];
         $sitepress_settings['translation-management']['custom_fields_translation']['_downloadable_files'] = $new_value;
         $sitepress_settings['translation-management']['custom_fields_translation']['_file_paths'] = $new_value;
         $sitepress->save_settings($sitepress_settings);
     }
     if (isset($_POST['wcml_trsl_interface_table']) && wp_verify_nonce($_POST['wcml_nonce'], 'wcml_trsl_interface_table')) {
         $woocommerce_wpml->settings['trnsl_interface'] = $_POST['trnsl_interface'];
         $woocommerce_wpml->update_settings();
     }
     if (isset($_POST['wcml_products_sync_prop']) && wp_verify_nonce($_POST['wcml_nonce'], 'wcml_products_sync_prop')) {
         $woocommerce_wpml->settings['products_sync_date'] = empty($_POST['products_sync_date']) ? 0 : 1;
         $woocommerce_wpml->update_settings();
     }
     if (isset($_GET['wcml_action']) && ($_GET['wcml_action'] = 'dismiss')) {
         $woocommerce_wpml->settings['dismiss_doc_main'] = 'yes';
         $woocommerce_wpml->update_settings();
     }
 }
 function woocommerce_currency()
 {
     if (!isset($this->constants['woocommerce_currency'])) {
         $this->constants['woocommerce_currency'] = $currency = function_exists('get_woocommerce_currency') ? get_woocommerce_currency() : "USD";
     } else {
         $currency = $this->constants['woocommerce_currency'];
     }
     return $currency;
 }
 /**
  * filter_reports.
  */
 function filter_reports($args)
 {
     //if ( ! isset( $_GET['currency'] ) ) return $args;
     if (isset($_GET['currency']) && 'merge' === $_GET['currency']) {
         return $args;
     }
     $args['where_meta'] = array(array('meta_key' => '_order_currency', 'meta_value' => isset($_GET['currency']) ? $_GET['currency'] : get_woocommerce_currency(), 'operator' => '='));
     return $args;
 }
 public function __construct()
 {
     //Set Global Variables
     global $homepage_json_fp, $homepage_json_ATC_link, $homepage_json_rp, $prodpage_json_relProd, $catpage_json, $prodpage_json_ATC_link, $catpage_json_ATC_link;
     //define plugin ID
     $this->id = "enhanced_ecommerce_google_analytics";
     $this->method_title = __("Enhanced Ecommerce Google Analytics", "enhanced-e-commerce-for-woocommerce-store");
     $this->method_description = __("Enhanced Ecommerce is a new feature of Universal Analytics that generates detailed statistics about the users journey from product page to thank you page on your e-store. <br/><a href='http://www.tatvic.com/blog/enhanced-ecommerce/' target='_blank'>Know more about Enhanced Ecommerce.</a><br/><br/><b>Quick Tip:</b> We recently launched an Advanced Google Analytics Plugin for WooCommerce! The plugin offers tracking of 9 Reports of Enhanced Ecommerce, User ID Tracking, 15+ Custom Dimenensions & Metrics, Content Grouping & much more. <a href='http://bit.ly/1yFqA04' target='_blank'>Learn More</a>", "woocommerce");
     //session for product position count //session_start removed bcoz it gives warning
     $_SESSION['t_npcnt'] = 0;
     $_SESSION['t_fpcnt'] = 0;
     // Load the integration form
     $this->init_form_fields();
     //load all the settings
     $this->init_settings();
     // Define user set variables -- Always use short names
     $this->ga_email = $this->get_option("ga_email");
     $this->ga_id = $this->get_option("ga_id");
     $this->ga_Dname = $this->get_option("ga_Dname");
     $this->ga_LC = get_woocommerce_currency();
     //Local Currency yuppi! Got from Back end
     //set local currency variable on all page
     $this->wc_version_compare("tvc_lc=" . json_encode($this->ga_LC) . ";");
     $this->ga_ST = $this->get_option("ga_ST");
     $this->ga_gCkout = $this->get_option("ga_gCkout") == "yes" ? true : false;
     //guest checkout
     $this->ga_gUser = $this->get_option("ga_gUser") == "yes" ? true : false;
     //guest checkout
     $this->ga_eeT = $this->get_option("ga_eeT");
     $this->ga_DF = $this->get_option("ga_DF") == "yes" ? true : false;
     $this->ga_imTh = $this->get_option("ga_imTh");
     //Save Changes action for admin settings
     add_action("woocommerce_update_options_integration_" . $this->id, array($this, "process_admin_options"));
     // API Call to LS with e-mail
     // Tracking code
     add_action("wp_head", array($this, "google_tracking_code"));
     add_action("woocommerce_thankyou", array($this, "ecommerce_tracking_code"));
     // Enhanced Ecommerce product impression hook
     add_action("wp_footer", array($this, "t_products_impre_clicks"));
     add_action("woocommerce_after_shop_loop_item", array($this, "bind_product_metadata"));
     //for cat, shop, prod(related),search and home page
     add_action("woocommerce_after_single_product", array($this, "product_detail_view"));
     add_action("woocommerce_after_cart", array($this, "remove_cart_tracking"));
     add_action("woocommerce_before_checkout_billing_form", array($this, "checkout_step_1_tracking"));
     add_action("woocommerce_after_checkout_billing_form", array($this, "checkout_step_2_tracking"));
     add_action("woocommerce_after_checkout_billing_form", array($this, "checkout_step_3_tracking"));
     // Event tracking code
     add_action("woocommerce_after_add_to_cart_button", array($this, "add_to_cart"));
     //Enable display feature code checkbox
     add_action("admin_footer", array($this, "admin_check_UA_enabled"));
     //add version details in footer
     add_action("wp_footer", array($this, "add_plugin_details"));
     //Add Dev ID
     add_action("wp_head", array($this, "add_dev_id"), 1);
     //Advanced Store data Tracking
     add_action("wp_footer", array($this, "tvc_store_meta_data"));
 }
 function init_shipping_fields_per_bairro()
 {
     global $woocommerce;
     $this->form_fields['per_postcode'] = array('title' => __('Por região :::::::::::', $this->id), 'type' => 'title');
     $count = $this->settings['per_postcode_count'];
     for ($counter = 1; $count >= $counter; $counter++) {
         $this->form_fields['per_postcode_' . $counter . '_postcode'] = array('title' => sprintf(__('Região #%s', $this->id), $counter), 'type' => 'textarea', 'description' => __('Digite as regiões no formato a seguir: UF|Cidade|Bairro;UF|Cidade|Bairro<br/>Exemplo: PR|Curitiba|Água Verde<br/>Para todos os bairros de uma cidade coloque *. <br/>Exemplo: PR|Curitiba|*<br/>***Atenção: Utilize a mesma nomenclatura dos correios.'), 'default' => '', 'placeholder' => 'UF|Cidade|Bairro;UF|Cidade|Bairro;...');
         $this->form_fields['per_postcode_' . $counter . '_fee'] = array('title' => sprintf(__('Taxa de entrega #%s', 'woocommerce'), $counter) . ' (' . get_woocommerce_currency() . ')', 'type' => 'text', 'description' => __('Set your quantity based shipping fee with semicolon (;) separated values for all postcodes specified above. Example:Quantity|Price;Quantity|Price. Example: 1|100;2|500.00 OR you can enter single price for all quantities Example: 100.00', $this->id), 'default' => '', 'placeholder' => '1|10.00');
     }
 }
 /**
  * Basic integration with WooCommerce Currency Switcher, developed by Aelia
  * (https://aelia.co). This method can be used by any 3rd party plugin to
  * return prices converted to the active currency.
  *
  * @param double amount The source price.
  * @param string to_currency The target currency. If empty, the active currency
  * will be taken.
  * @param string from_currency The source currency. If empty, WooCommerce base
  * currency will be taken.
  * @return double The price converted from source to destination currency.
  * @author Aelia <*****@*****.**>
  * @link https://aelia.co
  * @since 1.0.6
  */
 public static function get_amount_in_currency($amount, $to_currency = null, $from_currency = null)
 {
     if (empty($from_currency)) {
         $from_currency = self::base_currency();
     }
     if (empty($to_currency)) {
         $to_currency = get_woocommerce_currency();
     }
     return apply_filters('wc_aelia_cs_convert', $amount, $from_currency, $to_currency);
 }
 public function process_payment($order_id)
 {
     global $woocommerce;
     // Get customer order
     $customer_order = new WC_Order($order_id);
     // Generate URL
     $justgiving_qstr = array('amount' => $customer_order->order_total, 'reference' => woogiving_create_ref($order_id), 'currency' => get_woocommerce_currency(), 'exitUrl' => plugin_dir_url(__FILE__) . 'process.php?wg_action=process&wg_order_id=' . str_replace('#', '', $customer_order->get_order_number()) . '&jg_donation_id=JUSTGIVING-DONATION-ID');
     $justgiving_url = 'https://www.justgiving.com/' . rawurlencode($this->username) . '/4w350m3/donate/?' . http_build_query($justgiving_qstr);
     // Redirect to JustGiving
     return array('result' => 'success', 'redirect' => $justgiving_url);
 }
Example #27
0
 /**
  * add_edit_currency_symbol_field.
  */
 function add_edit_currency_symbol_field($settings)
 {
     $updated_settings = array();
     foreach ($settings as $section) {
         if (isset($section['id']) && 'woocommerce_currency_pos' == $section['id']) {
             $updated_settings[] = array('name' => __('Currency Symbol', 'woocommerce-jetpack'), 'desc_tip' => __('This sets the currency symbol.', 'woocommerce-jetpack'), 'id' => 'wcj_currency_' . get_woocommerce_currency(), 'type' => 'text', 'default' => get_woocommerce_currency_symbol(), 'desc' => apply_filters('get_wc_jetpack_plus_message', '', 'desc'), 'css' => 'width: 50px;', 'custom_attributes' => apply_filters('get_wc_jetpack_plus_message', '', 'readonly'));
         }
         $updated_settings[] = $section;
     }
     return $updated_settings;
 }
 /**
  * Process the payment and check if the currency is in PHP
  */
 function process_payment($order_id)
 {
     global $woocommerce;
     $order = new WC_Order($order_id);
     $woocommerce->cart->empty_cart();
     if (get_woocommerce_currency() == 'PHP' || get_woocommerce_currency() == 'php') {
         return array('result' => 'success', 'redirect' => $order->get_checkout_payment_url(true));
     } else {
         $woocommerce->add_error(__('Currency Error: ', 'woothemes') . "will only accept PHP currency.");
     }
 }
 protected function getDeclaredItems($order)
 {
     $items = array();
     $items['currency'] = strtoupper(get_woocommerce_currency());
     $order_items = $order->getWcOrder()->get_items();
     foreach ($order_items as $order_item) {
         $product = $order->getWcOrder()->get_product_from_item($order_item);
         $description = substr(get_post($product->id)->post_content, 0, 50);
         $items['ci_items'][] = array('product_name' => $product->get_title(), 'description' => !empty($description) ? $description : '', 'country_of_origin' => 'CA', 'quantity' => $order_item['qty'], 'unit_price' => $product->get_price(), 'unit_weight' => max(1, ceil(woocommerce_get_weight($product->get_weight(), 'kg'))), 'unit_of_measurement' => 'kilogram');
     }
     return $items;
 }
Example #30
0
 public function generate_form($order_id)
 {
     $order = new WC_Order($order_id);
     $action_adr = $this->liveurl;
     $result_url = str_replace('https:', 'http:', add_query_arg('wc-api', 'wc_privat24', get_permalink(woocommerce_get_page_id('thanks'))));
     $args = array('amt' => $order->order_total, 'ccy' => get_woocommerce_currency(), 'merchant' => $this->merchant_id, 'order' => $order_id, 'details' => "Оплата за заказ - {$order_id}", 'ext_details' => "Оплата за заказ - {$order_id}", 'pay_way' => 'privat24', 'return_url' => $result_url, 'server_url' => '');
     $args_array = array();
     foreach ($args as $key => $value) {
         $args_array[] = '<input type="hidden" name="' . esc_attr($key) . '" value="' . esc_attr($value) . '" />';
     }
     return '<form action="' . esc_url($action_adr) . '" method="POST" id="privat24_payment_form">' . '<input type="submit" class="button alt" id="submit_privat24_button" value="' . __('Оплатить', 'woocommerce') . '" /> <a class="button cancel" href="' . $order->get_cancel_order_url() . '">' . __('Отказаться от оплаты & вернуться в корзину', 'woocommerce') . '</a>' . "\n" . implode("\n", $args_array) . '</form>';
 }