本文整理汇总了PHP中woocommerce_price函数的典型用法代码示例。如果您正苦于以下问题:PHP woocommerce_price函数的具体用法?PHP woocommerce_price怎么用?PHP woocommerce_price使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了woocommerce_price函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: on_price_html
public function on_price_html($html, $_product)
{
$from = strstr($html, 'From') !== false ? ' From ' : ' ';
$discount_price = false;
$id = isset($_product->variation_id) ? $_product->variation_id : $_product->id;
$working_price = isset($this->discounted_products[$id]) ? $this->discounted_products[$id] : $_product->get_price();
$base_price = $_product->get_price();
if ($this->pricing_by_store_category->is_applied_to($_product)) {
if (floatval($working_price)) {
$discount_price = $this->pricing_by_store_category->get_price($_product, $working_price);
if ($discount_price && $discount_price != $base_price) {
$html = '<del>' . woocommerce_price($base_price) . '</del><ins>' . $from . woocommerce_price($discount_price) . '</ins>';
}
}
}
//Make sure we are using the price that was just discounted.
$working_price = $discount_price ? $discount_price : $base_price;
if ($this->pricing_by_membership->is_applied_to($_product)) {
$discount_price = $this->pricing_by_membership->get_price($_product, $working_price);
if (floatval($working_price)) {
if ($discount_price && $discount_price != $base_price) {
$html = '<del>' . woocommerce_price($base_price) . '</del><ins>' . $from . woocommerce_price($discount_price) . '</ins>';
}
}
}
$this->discounted_products[$id] = $discount_price ? $discount_price : $base_price;
return $html;
}
开发者ID:iplaydu,项目名称:Bob-Ellis-Shoes,代码行数:28,代码来源:woocommerce_dynamic_pricing.class.php
示例2: rpgc_custom_columns
/**
* Define our custom columns contents shown in admin.
* @param string $column
*
*/
function rpgc_custom_columns($column)
{
global $post;
$giftcardInfo = get_post_meta($post->ID, '_wpr_giftcard', true);
switch ($column) {
case "buyer":
echo '<div><strong>' . esc_html(isset($giftcardInfo['from']) ? $giftcardInfo['from'] : '') . '</strong><br />';
echo '<span style="font-size: 0.9em">' . esc_html(isset($giftcardInfo['fromEmail']) ? $giftcardInfo['fromEmail'] : '') . '</div>';
break;
case "recipient":
echo '<div><strong>' . esc_html(isset($giftcardInfo['to']) ? $giftcardInfo['to'] : '') . '</strong><br />';
echo '<span style="font-size: 0.9em">' . esc_html(isset($giftcardInfo['toEmail']) ? $giftcardInfo['toEmail'] : '') . '</span></div>';
break;
case "amount":
$price = isset($giftcardInfo['amount']) ? $giftcardInfo['amount'] : '';
echo woocommerce_price($price);
break;
case "balance":
$price = isset($giftcardInfo['balance']) ? $giftcardInfo['balance'] : '';
echo woocommerce_price($price);
break;
case "expiry_date":
$expiry_date = isset($giftcardInfo['expiry_date']) ? $giftcardInfo['expiry_date'] : '';
if ($expiry_date) {
echo esc_html(date_i18n('F j, Y', strtotime($expiry_date)));
} else {
echo '–';
}
break;
}
}
开发者ID:seanvfs,项目名称:gift-cards-for-woocommerce,代码行数:36,代码来源:post-type.php
示例3: rpgc_custom_columns
/**
* Define our custom columns shown in admin.
* @param string $column
*
*/
function rpgc_custom_columns($column)
{
global $post, $woocommerce;
switch ($column) {
case "buyer":
echo '<div><strong>' . esc_html(get_post_meta($post->ID, 'rpgc_from', true)) . '</strong><br />';
echo '<span style="font-size: 0.9em">' . esc_html(get_post_meta($post->ID, 'rpgc_email_from', true)) . '</div>';
break;
case "recipient":
echo '<div><strong>' . esc_html(get_post_meta($post->ID, 'rpgc_to', true)) . '</strong><br />';
echo '<span style="font-size: 0.9em">' . esc_html(get_post_meta($post->ID, 'rpgc_email_to', true)) . '</span></div>';
break;
case "amount":
$price = get_post_meta($post->ID, 'rpgc_amount', true);
echo woocommerce_price($price);
break;
case "balance":
$price = get_post_meta($post->ID, 'rpgc_balance', true);
echo woocommerce_price($price);
break;
case "expiry_date":
$expiry_date = get_post_meta($post->ID, 'rpgc_expiry_date', true);
if ($expiry_date) {
echo esc_html(date_i18n('F j, Y', strtotime($expiry_date)));
} else {
echo '–';
}
break;
}
}
开发者ID:seanvfs,项目名称:gift-cards-for-woocommerce,代码行数:35,代码来源:giftcard-columns.php
示例4: woocommerce_bundle_price_html
/**
* Converts the price for a bundled product. With bundled products, price
* is passed "as-is" and it doesn't get converted into currency.
*
* @param string bundle_price_html The HTML snippet containing a
* bundle's regular price in base currency.
* @param WC_Product product The product being displayed.
* @return string The HTML snippet with the price converted into currently
* selected currency.
*/
public function woocommerce_bundle_price_html($bundle_price_html, $product)
{
$product = $this->convert_product_prices($product);
$bundle_price_html = $product->get_price_html_from_text();
$bundle_price_html .= woocommerce_price($product->min_bundle_price);
return $bundle_price_html;
}
开发者ID:keshvenderg,项目名称:cloudshop,代码行数:17,代码来源:wc-aelia-cs-bundles-integration.php
示例5: price
function price($vlaue, $args = array())
{
$currency = isset($args['currency']) ? $args['currency'] : '';
if (!$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'];
}
}
$args['currency'] = $currency;
$vlaue = trim($vlaue);
$withoutdecimal = str_replace(".", "d", $vlaue);
if (!isset($this->constants['price_format'][$currency][$withoutdecimal])) {
if (!function_exists('woocommerce_price')) {
if (!isset($this->constants['currency_symbol'])) {
$this->constants['currency_symbol'] = $currency_symbol = apply_filters('ic_commerce_currency_symbol', '$', 'USD');
} else {
$currency_symbol = $this->constants['currency_symbol'];
}
$vlaue = strlen(trim($vlaue)) > 0 ? $vlaue : 0;
$v = $currency_symbol . "" . number_format($vlaue, 2, '.', ' ');
$v = "<span class=\"amount\">{$v}</span>";
} else {
$v = woocommerce_price($vlaue, $args);
}
$this->constants['price_format'][$currency][$withoutdecimal] = $v;
} else {
$v = $this->constants['price_format'][$currency][$withoutdecimal];
}
return $v;
}
开发者ID:developmentDM2,项目名称:The-Haute-Mess,代码行数:32,代码来源:ic_commerce_variation_fuctions.php
示例6: __construct
public function __construct()
{
$this->id = 'accountfunds';
$this->method_title = __('Account Funds', 'woocommerce');
// Support subscriptions
$this->supports = array('subscriptions', 'products', 'subscription_cancellation', 'subscription_reactivation', 'subscription_suspension', 'subscription_amount_changes', 'subscription_payment_method_change', 'subscription_date_changes');
// Load the form fields.
$this->init_form_fields();
// Load the settings.
$this->init_settings();
$this->title = $this->settings['title'];
$wcaf_settings = get_option('wcaf_settings');
$desc = sprintf(__("Available balance: %s", 'wc_account_funds'), x3m_get_account_funds());
if ($wcaf_settings['give_discount'] == 1 && $wcaf_settings['discount_amount'] > 0) {
$desc .= __('<br/>Use your account funds and get a %s discount on your order', 'wc_account_funds');
$amount = floatval($wcaf_settings['discount_amount']);
if ($wcaf_settings['discount_type'] == 'fixed') {
$desc = sprintf($desc, woocommerce_price($amount));
} else {
$desc = sprintf($desc, $amount . '%');
}
}
$this->description = $desc;
add_action('woocommerce_update_options_payment_gateways', array(&$this, 'process_admin_options'));
add_action('woocommerce_update_options_payment_gateways_' . $this->id, array(&$this, 'process_admin_options'));
// Subscriptons
add_action('scheduled_subscription_payment_' . $this->id, array($this, 'scheduled_subscription_payment'), 10, 3);
// display the current payment method used for a subscription in the "My Subscriptions" table
add_filter('woocommerce_my_subscriptions_recurring_payment_method', array($this, 'subscription_payment_method_name'), 10, 3);
}
开发者ID:bulbulbigboss,项目名称:bigboss-woocommerce-deposit-funds,代码行数:30,代码来源:Bigboss-WooCommerce-deposit-funds-getaways.php
示例7: pay_now
/**
* Pay all outstanding commission using Paypal Mass Pay
*
* @return array
*/
public static function pay_now()
{
$mass_pay = new WCV_Mass_Pay();
$mass_pay = $mass_pay->do_payments();
$message = !empty($mass_pay['total']) ? $mass_pay['msg'] . '<br/>' . sprintf(__('Payment total: %s', 'wcvendors'), woocommerce_price($mass_pay['total'])) : $mass_pay['msg'];
return array('message' => $message, 'status' => $mass_pay['status']);
}
开发者ID:shubham79,项目名称:Jhintaak,代码行数:12,代码来源:class-cron.php
示例8: road_woo_price_html
function road_woo_price_html($price, $product)
{
if ($product->product_type == "variable") {
if ($product->get_variation_sale_price() && $product->get_variation_regular_price() != $product->get_variation_sale_price()) {
$rprice = $product->get_variation_regular_price();
$sprice = $product->get_variation_sale_price();
return '<span class="special-price">' . (is_numeric($sprice) ? woocommerce_price($sprice) : $sprice) . '</span><span class="old-price">' . (is_numeric($rprice) ? woocommerce_price($rprice) : $rprice) . '</span>';
} else {
$rprice = $product->get_variation_regular_price();
return '<span class="special-price">' . (is_numeric($rprice) ? woocommerce_price($rprice) : $rprice) . '</span>';
}
}
if ($product->price > 0) {
if ($product->price && isset($product->regular_price) && $product->price != $product->regular_price) {
$rprice = $product->regular_price;
$sprice = $product->price;
return '<span class="special-price">' . (is_numeric($sprice) ? woocommerce_price($sprice) : $sprice) . '</span><span class="old-price">' . (is_numeric($rprice) ? woocommerce_price($rprice) : $rprice) . '</span>';
} else {
$sprice = $product->price;
return '<span class="special-price">' . (is_numeric($sprice) ? woocommerce_price($sprice) : $sprice) . '</span>';
}
} else {
return '<span class="special-price">0</span>';
}
}
开发者ID:andersonaguiaralves,项目名称:meiotomloja,代码行数:25,代码来源:functions.php
示例9: widget
function widget($args, $instance)
{
$me = wp_get_current_user();
if ($me->ID == 0) {
return;
}
$funds = get_user_meta($me->ID, 'account_funds', true);
if (empty($funds)) {
$funds = 0;
}
extract($args);
$title = apply_filters('widget_title', $instance['title']);
echo $before_widget;
if (!empty($title)) {
echo $before_title . $title . $after_title;
}
?>
<p><?php
printf(__('You currently have <b>%s</b> in your account', 'wc_account_funds'), woocommerce_price($funds));
?>
</p>
<p style="text-align:center;"><a class="button" href="<?php
echo get_permalink(woocommerce_get_page_id('myaccount'));
?>
"><?php
_e('Deposit Funds', 'wc_account_funds');
?>
</a></p>
<?php
echo $after_widget;
}
开发者ID:bulbulbigboss,项目名称:bigboss-woocommerce-deposit-funds,代码行数:31,代码来源:widget.php
示例10: render_input
function render_input($args, $options = "", $default = "")
{
$_html = '';
foreach ($options as $opt) {
if ($default) {
if (in_array($opt['option'], $default)) {
$checked = 'checked="checked"';
} else {
$checked = '';
}
}
if ($opt['price']) {
$output = stripslashes(trim($opt['option'])) . ' (+ ' . woocommerce_price($opt['price']) . ')';
} else {
$output = stripslashes(trim($opt['option']));
}
$field_id = $args['name'] . '-meta-' . strtolower(preg_replace("![^a-z0-9]+!i", "_", $opt['option']));
$_html .= '<label for="' . $field_id . '"> <input id="' . $field_id . '" data-price="' . $opt['price'] . '" type="checkbox" ';
foreach ($args as $attr => $value) {
if ($attr == 'name') {
$value .= '[]';
}
$_html .= $attr . '="' . stripslashes($value) . '"';
}
$_html .= ' value="' . $opt['option'] . '" ' . $checked . '>';
$_html .= $output;
$_html .= '</label>';
}
echo $_html;
}
开发者ID:GermansRegi,项目名称:wordpress-bacicleta,代码行数:30,代码来源:input.checkbox.php
示例11: display_price_in_variation_option_name
function display_price_in_variation_option_name($term)
{
global $wpdb, $product;
$term_temp = $term;
$term = strtolower($term);
$term = str_replace(' ', '-', $term);
$result = $wpdb->get_col("SELECT slug FROM {$wpdb->prefix}terms WHERE name = '{$term}'");
$term_slug = !empty($result) ? $result[0] : $term;
$query = "SELECT postmeta.post_id AS product_id\nFROM {$wpdb->prefix}postmeta AS postmeta\nLEFT JOIN {$wpdb->prefix}posts AS products ON ( products.ID = postmeta.post_id )\nWHERE postmeta.meta_key LIKE 'attribute_%'\nAND postmeta.meta_value = '{$term_slug}'\nAND products.post_parent = {$product->id}";
$variation_id = $wpdb->get_col($query);
$parent = wp_get_post_parent_id($variation_id[0]);
if ($parent > 0) {
$_product = new WC_Product_Variation($variation_id[0]);
$testVariable = $_product->get_variation_attributes();
$itemPrice = strip_tags(woocommerce_price($_product->get_price()));
$getPrice = $_product->get_price();
$itemPriceInt = (int) $getPrice;
$term = $term_temp;
//this is where you can actually customize how the price is displayed
if ($itemPriceInt > 0) {
return $term . ' (' . $itemPrice . ' incl. GST)';
} else {
return $term . ' (' . $itemPrice . ')';
}
}
return $term;
}
开发者ID:Ezyva2015,项目名称:SMSF-Academy-Wordpress,代码行数:27,代码来源:woo-functions.php
示例12: get_cart_item_data
/**
* Process this field after being posted
* @return array on success, WP_ERROR on failure
*/
public function get_cart_item_data()
{
$cart_item_data = array();
foreach ($this->addon['options'] as $key => $option) {
$option_key = empty($option['label']) ? $key : sanitize_title($option['label']);
$posted = isset($this->value[$option_key]) ? $this->value[$option_key] : '';
if ($posted === '') {
continue;
}
$label = $this->get_option_label($option);
$price = $this->get_option_price($option);
switch ($this->addon['type']) {
case "custom_price":
$price = floatval(sanitize_text_field($posted));
if ($price >= 0) {
$cart_item_data[] = array('name' => $label, 'value' => $price, 'price' => $price, 'display' => strip_tags(woocommerce_price($price)));
}
break;
case "input_multiplier":
$posted = absint($posted);
$cart_item_data[] = array('name' => $label, 'value' => $posted, 'price' => $posted * $price);
break;
default:
$cart_item_data[] = array('name' => $label, 'value' => wp_kses_post($posted), 'price' => $price);
break;
}
}
return $cart_item_data;
}
开发者ID:brian3t,项目名称:orchidmate,代码行数:33,代码来源:class-product-addon-field-custom.php
示例13: wcml_convert_price
function wcml_convert_price($formatted, $unformatted)
{
if (!is_admin()) {
$currency = apply_filters('wcml_price_currency', get_woocommerce_currency());
$formatted = strip_tags(woocommerce_price(apply_filters('wcml_raw_price_amount', $unformatted), array('currency' => $currency)));
}
return $formatted;
}
开发者ID:sergioblanco86,项目名称:git-gitlab.com-kinivo-kinivo.com,代码行数:8,代码来源:gravityforms.class.php
示例14: mp_price
function mp_price($vlaue)
{
if (!function_exists('woocommerce_price') || 'WC_IS_MIS_WC_ACITVE' == false) {
return apply_filters('mp_currency_symbol', '$', 'USD') . $vlaue;
} else {
return woocommerce_price($vlaue);
}
}
开发者ID:pcuervo,项目名称:mobbily-wordpress,代码行数:8,代码来源:product-list_orig.php
示例15: format_price
public static function format_price($price)
{
if (function_exists('woocommerce_price')) {
return woocommerce_price($price);
} else {
return wc_price($price);
}
}
开发者ID:bear12345678,项目名称:keylessoption,代码行数:8,代码来源:class_list_table_fp_rac_recovered_order.php
示例16: wc_price
public static function wc_price($price)
{
if (self::is_wc_version_gte_2_1()) {
return wc_price($price);
} else {
return woocommerce_price($price);
}
}
开发者ID:GarryVeles,项目名称:Artibaltika,代码行数:8,代码来源:class-wc-dynamic-pricing-compatibility.php
示例17: cs_product_parceled
/**
* Calculates the price in 3 installments without interest.
*
* @return string Price in 3 installments.
*/
function cs_product_parceled()
{
$product = get_product();
if ($product->get_price_including_tax()) {
$value = woocommerce_price($product->get_price_including_tax() / 3);
return $value;
}
}
开发者ID:zerocowl,项目名称:desventuras,代码行数:13,代码来源:plg_parcela.php
示例18: custom_variation_price
function custom_variation_price($price, $product)
{
$price = '';
if (!$product->min_variation_price || $product->min_variation_price !== $product->max_variation_price) {
$price .= '<span class="from">' . _x('From', 'min_price', 'woocommerce') . ' </span>';
$price .= woocommerce_price($product->get_price());
}
return $price;
}
开发者ID:TakenCdosG,项目名称:chefs,代码行数:9,代码来源:functions.php
示例19: custom_variation_price
function custom_variation_price($price, $product)
{
$price = '';
if (!$product->min_variation_price || $product->min_variation_price !== $product->max_variation_price) {
$price .= '<p style="margin-bottom: -10px !important; padding: 0 !important;"><span class="from" style="color: #000;">' . _x('From', 'min_price', 'woocommerce') . ' </span></p>';
}
$price .= woocommerce_price($product->min_variation_price);
return $price;
}
开发者ID:jyri363,项目名称:pizzakuller-themes,代码行数:9,代码来源:custom-functions.php
示例20: woocommerce_gravityforms_get_updated_price
function woocommerce_gravityforms_get_updated_price()
{
global $woocommerce;
header('Cache-Control: no-cache, must-revalidate');
header('Content-type: application/json');
$variation_id = isset($_POST['variation_id']) ? $_POST['variation_id'] : '';
$product_id = isset($_POST['product_id']) ? $_POST['product_id'] : 0;
$gform_total = isset($_POST['gform_total']) ? $_POST['gform_total'] : 0;
$product_data = null;
if (function_exists('get_product')) {
$product_data = get_product($variation_id > 0 ? $variation_id : $product_id);
} else {
if ($variation_id > 0) {
$product_data = new WC_Product_Variation($variation_id);
} else {
$product_data = new WC_Product($product_id);
}
}
$discount_price = false;
$gforms_discount_price = false;
$base_price = $product_data->get_price();
if (class_exists('WC_Dynamic_Pricing')) {
$working_price = $base_price;
$dynamic_pricing = WC_Dynamic_Pricing::instance();
foreach ($dynamic_pricing->modules as $module) {
if ($module->module_type == 'simple') {
//Make sure we are using the price that was just discounted.
$working_price = $discount_price ? $discount_price : $base_price;
$working_price = $module->get_product_working_price($working_price, $product_data);
if (floatval($working_price)) {
$discount_price = $module->get_discounted_price_for_shop($product_data, $working_price);
}
}
}
$gforms_base_price = $base_price + $gform_total;
$gforms_working_price = $base_price + $gform_total;
foreach ($dynamic_pricing->modules as $module) {
if ($module->module_type == 'simple') {
//Make sure we are using the price that was just discounted.
$gforms_working_price = $gforms_discount_price ? $gforms_discount_price : $gforms_base_price;
$gforms_working_price = $module->get_product_working_price($gforms_working_price, $product_data);
if (floatval($gforms_working_price)) {
$gforms_discount_price = $module->get_discounted_price_for_shop($product_data, $gforms_working_price);
}
}
}
}
$price = $discount_price ? $discount_price : $base_price;
$gform_final_total = $gforms_discount_price ? $gforms_discount_price : $price + $gform_total;
$result = array('formattedBasePrice' => apply_filters('woocommerce_gform_base_price', woocommerce_price($price), $product_data), 'formattedTotalPrice' => apply_filters('woocommerce_gform_total_price', woocommerce_price($gform_final_total), $product_data), 'formattedVariationTotal' => apply_filters('woocommerce_gform_variation_total_price', woocommerce_price($gform_total), $product_data));
echo json_encode($result);
die;
}
开发者ID:avijitdeb,项目名称:flatterbox.com,代码行数:53,代码来源:gravityforms-product-addons-ajax.php
注:本文中的woocommerce_price函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论