当前位置: 首页>>代码示例>>PHP>>正文


PHP get_woocommerce_currency函数代码示例

本文整理汇总了PHP中get_woocommerce_currency函数的典型用法代码示例。如果您正苦于以下问题:PHP get_woocommerce_currency函数的具体用法?PHP get_woocommerce_currency怎么用?PHP get_woocommerce_currency使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_woocommerce_currency函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 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);
 }
开发者ID:Hygglig,项目名称:New_Hygglig_WooCommerce,代码行数:28,代码来源:gateway-hygglig.php

示例2: calculate_shipping

 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;
     }
 }
开发者ID:mjtarter,项目名称:y8,代码行数:29,代码来源:class-printful-shipping.php

示例3: process_subscription_payment

 /**
  * 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;
 }
开发者ID:tccyp001,项目名称:onemore-wordpress,代码行数:33,代码来源:class-s4wc_subscriptions_gateway.php

示例4: get_currency_countries

 /**
  * 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;
 }
开发者ID:algoritmika,项目名称:woocommerce-jetpack,代码行数:36,代码来源:class-wcj-price-by-country-group-generator.php

示例5: accounting

 /**
  * 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));
 }
开发者ID:rpidanny,项目名称:WooCommerce-POS,代码行数:13,代码来源:class-wc-pos-params.php

示例6: pay

 /**
  * 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 <antonio.larocca@yithemes.it>
  */
 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'));
 }
开发者ID:shwetadubey,项目名称:upfit,代码行数:48,代码来源:class-yith-gateway-paypal.php

示例7: is_valid_for_use

 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;
 }
开发者ID:parkmap,项目名称:woocommerce-paygate-jt,代码行数:7,代码来源:class-wc-gateway-paygate-bank.php

示例8: admin_options

    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']);
        }
    }
开发者ID:Send24com,项目名称:Send24-for-WooCommerce,代码行数:33,代码来源:class.shipping_method.php

示例9: cs_product_parceled_single

/**
 * 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 
}
开发者ID:zerocowl,项目名称:desventuras,代码行数:37,代码来源:plg_parcela.php

示例10: is_valid_for_use

 /**
  * 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;
 }
开发者ID:renannprado,项目名称:woocommerce-komerci,代码行数:12,代码来源:class-wc-komerci-gateway.php

示例11: makePayload

 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;
 }
开发者ID:flagshipcompany,项目名称:flagship-for-woocommerce,代码行数:28,代码来源:MetaBoxViewerFactory.php

示例12: generate_razorpay_form

        /**
         * 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;
        }
开发者ID:kdclabs,项目名称:razorpay-woocommerce,代码行数:38,代码来源:razorpay-payments.php

示例13: init_form_fields

 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');
     }
 }
开发者ID:jquiterio,项目名称:meowallet,代码行数:7,代码来源:meowallet.php

示例14: maybe_show_admin_notices

 /**
  * 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';
     }
 }
开发者ID:DustinHartzler,项目名称:TheCLEFT,代码行数:36,代码来源:class-wcs-paypal-admin.php

示例15: vc_gitem_template_attribute_woocommerce_product

/**
 * 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) : '';
}
开发者ID:chicosilva,项目名称:olharambiental,代码行数:67,代码来源:grid-item-attributes.php


注:本文中的get_woocommerce_currency函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。