本文整理汇总了PHP中WC_Product_Variable::get_price方法的典型用法代码示例。如果您正苦于以下问题:PHP WC_Product_Variable::get_price方法的具体用法?PHP WC_Product_Variable::get_price怎么用?PHP WC_Product_Variable::get_price使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WC_Product_Variable
的用法示例。
在下文中一共展示了WC_Product_Variable::get_price方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_RP_WCDPD
public function get_RP_WCDPD($product, $field_price = null, $cart_item_key = null)
{
$price = null;
if (class_exists('RP_WCDPD') && class_exists('RP_WCDPD_Pricing') && !empty($GLOBALS['RP_WCDPD'])) {
$tm_RP_WCDPD = $GLOBALS['RP_WCDPD'];
$selected_rule = null;
if ($field_price !== null && $cart_item_key !== null) {
return $this->get_RP_WCDPD_single($field_price, $cart_item_key, $tm_RP_WCDPD->pricing);
}
$dpd_version_compare = version_compare(RP_WCDPD_VERSION, '1.0.13', '<');
// Iterate over pricing rules and use the first one that has this product in conditions (or does not have if condition "not in list")
if (isset($tm_RP_WCDPD->opt['pricing']['sets']) && count($tm_RP_WCDPD->opt['pricing']['sets'])) {
foreach ($tm_RP_WCDPD->opt['pricing']['sets'] as $rule_key => $rule) {
if ($rule['method'] == 'quantity' && ($validated_rule = RP_WCDPD_Pricing::validate_rule($rule))) {
if ($dpd_version_compare) {
if ($validated_rule['selection_method'] == 'all' && $tm_RP_WCDPD->user_matches_rule($validated_rule['user_method'], $validated_rule['roles'])) {
$selected_rule = $validated_rule;
break;
}
if ($validated_rule['selection_method'] == 'categories_include' && count(array_intersect($tm_RP_WCDPD->get_product_categories($product->id), $validated_rule['categories'])) > 0 && $tm_RP_WCDPD->user_matches_rule($validated_rule['user_method'], $validated_rule['roles'])) {
$selected_rule = $validated_rule;
break;
}
if ($validated_rule['selection_method'] == 'categories_exclude' && count(array_intersect($tm_RP_WCDPD->get_product_categories($product->id), $validated_rule['categories'])) == 0 && $tm_RP_WCDPD->user_matches_rule($validated_rule['user_method'], $validated_rule['roles'])) {
$selected_rule = $validated_rule;
break;
}
if ($validated_rule['selection_method'] == 'products_include' && in_array($product->id, $validated_rule['products']) && $tm_RP_WCDPD->user_matches_rule($validated_rule['user_method'], $validated_rule['roles'])) {
$selected_rule = $validated_rule;
break;
}
if ($validated_rule['selection_method'] == 'products_exclude' && !in_array($product->id, $validated_rule['products']) && $tm_RP_WCDPD->user_matches_rule($validated_rule['user_method'], $validated_rule['roles'])) {
$selected_rule = $validated_rule;
break;
}
} else {
if ($validated_rule['selection_method'] == 'all' && $tm_RP_WCDPD->user_matches_rule($validated_rule)) {
$selected_rule = $validated_rule;
break;
}
if ($validated_rule['selection_method'] == 'categories_include' && count(array_intersect($tm_RP_WCDPD->get_product_categories($product->id), $validated_rule['categories'])) > 0 && $tm_RP_WCDPD->user_matches_rule($validated_rule)) {
$selected_rule = $validated_rule;
break;
}
if ($validated_rule['selection_method'] == 'categories_exclude' && count(array_intersect($tm_RP_WCDPD->get_product_categories($product->id), $validated_rule['categories'])) == 0 && $tm_RP_WCDPD->user_matches_rule($validated_rule)) {
$selected_rule = $validated_rule;
break;
}
if ($validated_rule['selection_method'] == 'products_include' && in_array($product->id, $validated_rule['products']) && $tm_RP_WCDPD->user_matches_rule($validated_rule)) {
$selected_rule = $validated_rule;
break;
}
if ($validated_rule['selection_method'] == 'products_exclude' && !in_array($product->id, $validated_rule['products']) && $tm_RP_WCDPD->user_matches_rule($validated_rule)) {
$selected_rule = $validated_rule;
break;
}
}
}
}
}
if (is_array($selected_rule)) {
// Quantity
if ($selected_rule['method'] == 'quantity' && isset($selected_rule['pricing']) && in_array($selected_rule['quantities_based_on'], array('exclusive_product', 'exclusive_variation', 'exclusive_configuration'))) {
if ($product->product_type == 'variable' || $product->product_type == 'variable-subscription') {
$product_variations = $product->get_available_variations();
}
// For variable products only - check if prices differ for different variations
$multiprice_variable_product = false;
if (($product->product_type == 'variable' || $product->product_type == 'variable') && !empty($product_variations)) {
$last_product_variation = array_slice($product_variations, -1);
$last_product_variation_object = new WC_Product_Variable($last_product_variation[0]['variation_id']);
$last_product_variation_price = $last_product_variation_object->get_price();
foreach ($product_variations as $variation) {
$variation_object = new WC_Product_Variable($variation['variation_id']);
if ($variation_object->get_price() != $last_product_variation_price) {
$multiprice_variable_product = true;
}
}
}
if ($multiprice_variable_product) {
$variation_table_data = array();
foreach ($product_variations as $variation) {
$variation_product = new WC_Product_Variation($variation['variation_id']);
$variation_table_data[$variation['variation_id']] = $tm_RP_WCDPD->pricing_table_calculate_adjusted_prices($selected_rule['pricing'], $variation_product->get_price());
}
$price = array();
$price['is_multiprice'] = true;
$price['rules'] = $variation_table_data;
} else {
if ($product->product_type == 'variable' && !empty($product_variations)) {
$variation_product = new WC_Product_Variation($last_product_variation[0]['variation_id']);
$table_data = $tm_RP_WCDPD->pricing_table_calculate_adjusted_prices($selected_rule['pricing'], $variation_product->get_price());
} else {
$table_data = $tm_RP_WCDPD->pricing_table_calculate_adjusted_prices($selected_rule['pricing'], $product->get_price());
}
$price = array();
$price['is_multiprice'] = false;
$price['rules'] = $table_data;
}
}
//.........这里部分代码省略.........
示例2: product_page_pricing_table
/**
* Maybe display pricing table or anchor to display pricing table in modal
*
* @access public
* @return void
*/
public function product_page_pricing_table()
{
if ($this->opt['settings']['display_table'] == 'hide' && (!isset($this->opt['settings']['display_offers']) || $this->opt['settings']['display_offers'] == 'hide')) {
return;
}
global $product;
if (!$product) {
return;
}
// Load required classes
require_once RP_WCDPD_PLUGIN_PATH . 'includes/classes/Pricing.php';
$selected_rule = null;
// Iterate over pricing rules and use the first one that has this product in conditions (or does not have if condition "not in list")
if (isset($this->opt['pricing']['sets']) && count($this->opt['pricing']['sets'])) {
foreach ($this->opt['pricing']['sets'] as $rule_key => $rule) {
if ($rule['method'] == 'quantity' && ($validated_rule = RP_WCDPD_Pricing::validate_rule($rule))) {
if ($validated_rule['selection_method'] == 'all' && $this->user_matches_rule($validated_rule)) {
$selected_rule = $validated_rule;
break;
}
if ($validated_rule['selection_method'] == 'categories_include' && count(array_intersect($this->get_product_categories($product->id), $validated_rule['categories'])) > 0 && $this->user_matches_rule($validated_rule)) {
$selected_rule = $validated_rule;
break;
}
if ($validated_rule['selection_method'] == 'categories_exclude' && count(array_intersect($this->get_product_categories($product->id), $validated_rule['categories'])) == 0 && $this->user_matches_rule($validated_rule)) {
$selected_rule = $validated_rule;
break;
}
if ($validated_rule['selection_method'] == 'products_include' && in_array($product->id, $validated_rule['products']) && $this->user_matches_rule($validated_rule)) {
$selected_rule = $validated_rule;
break;
}
if ($validated_rule['selection_method'] == 'products_exclude' && !in_array($product->id, $validated_rule['products']) && $this->user_matches_rule($validated_rule)) {
$selected_rule = $validated_rule;
break;
}
}
}
}
if (is_array($selected_rule)) {
// Quantity
if ($selected_rule['method'] == 'quantity' && in_array($this->opt['settings']['display_table'], array('modal', 'inline')) && isset($selected_rule['pricing'])) {
if ($product->product_type == 'variable') {
$product_variations = $product->get_available_variations();
}
// For variable products only - check if prices differ for different variations
$multiprice_variable_product = false;
if ($product->product_type == 'variable' && !empty($product_variations)) {
$last_product_variation = array_slice($product_variations, -1);
$last_product_variation_object = new WC_Product_Variable($last_product_variation[0]['variation_id']);
$last_product_variation_price = $last_product_variation_object->get_price();
foreach ($product_variations as $variation) {
$variation_object = new WC_Product_Variable($variation['variation_id']);
if ($variation_object->get_price() != $last_product_variation_price) {
$multiprice_variable_product = true;
}
}
}
if ($multiprice_variable_product) {
$variation_table_data = array();
foreach ($product_variations as $variation) {
$variation_product = new WC_Product_Variation($variation['variation_id']);
$variation_table_data[$variation['variation_id']] = $this->pricing_table_calculate_adjusted_prices($selected_rule['pricing'], $variation_product->get_price());
}
require_once RP_WCDPD_PLUGIN_PATH . 'includes/views/frontend/table-variable.php';
} else {
if ($product->product_type == 'variable' && !empty($product_variations)) {
$variation_product = new WC_Product_Variation($last_product_variation[0]['variation_id']);
$table_data = $this->pricing_table_calculate_adjusted_prices($selected_rule['pricing'], $variation_product->get_price());
} else {
$table_data = $this->pricing_table_calculate_adjusted_prices($selected_rule['pricing'], $product->get_price());
}
require_once RP_WCDPD_PLUGIN_PATH . 'includes/views/frontend/table-' . $this->opt['settings']['display_table'] . '-' . $this->opt['settings']['pricing_table_style'] . '.php';
}
}
}
}
示例3: fp_rac_cron_job_mailing
public static function fp_rac_cron_job_mailing()
{
global $wpdb;
global $woocommerce;
global $to;
global $user_lang;
$emailtemplate_table_name = $wpdb->prefix . 'rac_templates_email';
$abandancart_table_name = $wpdb->prefix . 'rac_abandoncart';
$email_templates = $wpdb->get_results("SELECT * FROM {$emailtemplate_table_name}");
//all email templates
$abandon_carts = $wpdb->get_results("SELECT * FROM {$abandancart_table_name} WHERE cart_status='ABANDON' AND user_id!='0' AND completed IS NULL");
//Selected only cart which are not completed
// For Members
foreach ($abandon_carts as $each_cart) {
foreach ($email_templates as $emails) {
if ($emails->status == "ACTIVE") {
$cart_array = maybe_unserialize($each_cart->cart_details);
$tablecheckproduct = "<table style='width:100%;border:1px solid #eee;'><thead><tr>";
if (get_option('rac_hide_product_name_product_info_shortcode') != 'yes') {
$tablecheckproduct .= "<th style='text-align:left;border:1px solid #eee;padding:12px' scope='col'>" . fp_get_wpml_text('rac_template_product_name', $each_cart->wpml_lang, get_option('rac_product_info_product_name')) . "</th>";
}
if (get_option('rac_hide_product_image_product_info_shortcode') != 'yes') {
$tablecheckproduct .= "<th style='text-align:left;border:1px solid #eee;padding:12px' scope='col'>" . fp_get_wpml_text('rac_template_product_image', $each_cart->wpml_lang, get_option('rac_product_info_product_image')) . "</th>";
}
if (get_option('rac_hide_product_price_product_info_shortcode') != 'yes') {
$tablecheckproduct .= "<th style='text-align:left;border:1px solid #eee;padding:12px' scope='col'>" . fp_get_wpml_text('rac_template_product_price', $each_cart->wpml_lang, get_option('rac_product_info_product_price')) . "</th>";
}
$tablecheckproduct .= "</tr></thead><tbody>";
if (is_array($cart_array)) {
foreach ($cart_array as $cart) {
foreach ($cart as $inside) {
foreach ($inside as $product) {
if ((double) $woocommerce->version <= (double) '2.0.20') {
$objectproduct = get_product($product['product_id']);
$objectproductvariable = get_product($product['variation_id']);
} else {
$objectproduct = new WC_Product($product['product_id']);
$objectproductvariable = new WC_Product_Variation($product['variation_id']);
}
$tablecheckproduct .= "<tr>";
if (get_option('rac_hide_product_name_product_info_shortcode') != 'yes') {
$tablecheckproduct .= "<td style='text-align:left;vertical-align:middle;border:1px solid #eee;word-wrap:break-word;padding:12px'>" . get_the_title($product['product_id']) . "</td>";
}
if (get_option('rac_hide_product_image_product_info_shortcode') != 'yes') {
$tablecheckproduct .= "<td style='text-align:left;vertical-align:middle;border:1px solid #eee;word-wrap:break-word;padding:12px'>" . get_the_post_thumbnail($product['product_id'], array(90, 90)) . "</td>";
}
if (get_option('rac_hide_product_price_product_info_shortcode') != 'yes') {
$tablecheckproduct .= "<td style='text-align:left;vertical-align:middle;border:1px solid #eee;word-wrap:break-word;padding:12px'>" . self::get_rac_formatprice($product['variation_id'] == '' ? $objectproduct->get_price() : $objectproductvariable->get_price()) . "</td>";
}
$tablecheckproduct .= "</tr>";
}
}
}
/* $tablecheckproduct .= "It is from Array";
$dump = print_r($cart_array, true);
$tablecheckproduct .= $dump; */
} elseif (is_object($cart_array)) {
$order = new WC_Order($cart_array->id);
if ($order->user_id != '') {
foreach ($order->get_items() as $products) {
if ((double) $woocommerce->version <= (double) '2.0.20') {
$objectproduct = get_product($products['product_id']);
$objectproductvariable = get_product($products['variation_id']);
} else {
$objectproduct = new WC_Product($products['product_id']);
$objectproductvariable = new WC_Product_Variation($products['variation_id']);
}
$tablecheckproduct .= "<tr>";
if (get_option('rac_hide_product_name_product_info_shortcode') != 'yes') {
$tablecheckproduct .= "<td style='text-align:left;vertical-align:middle;border:1px solid #eee;word-wrap:break-word;padding:12px'>" . get_the_title($products['product_id']) . "</td>";
}
if (get_option('rac_hide_product_image_product_info_shortcode') != 'yes') {
$tablecheckproduct .= "<td style='text-align:left;vertical-align:middle;border:1px solid #eee;word-wrap:break-word;padding:12px'>" . get_the_post_thumbnail($products['product_id'], array(90, 90)) . "</td>";
}
if (get_option('rac_hide_product_price_product_info_shortcode') != 'yes') {
$tablecheckproduct .= "<td style='text-align:left;vertical-align:middle;border:1px solid #eee;word-wrap:break-word;padding:12px'>" . self::get_rac_formatprice($products['variation_id'] == '' ? $objectproduct->get_price() : $objectproductvariable->get_price()) . "</td>";
}
$tablecheckproduct .= "</tr>";
}
}
/* $tablecheckproduct .= "It is from Object";
$tablecheckproduct .= var_dump($cart_array); */
}
$tablecheckproduct .= "</table>";
if (get_option('rac_email_use_members') == 'yes') {
if (empty($each_cart->mail_template_id)) {
// IF EMPTY IT IS NOT SENT FOR ANY SINGLE TEMPLATE
if ($emails->sending_type == 'hours') {
$duration = $emails->sending_duration * 3600;
} else {
if ($emails->sending_type == 'minutes') {
$duration = $emails->sending_duration * 60;
} else {
if ($emails->sending_type == 'days') {
$duration = $emails->sending_duration * 86400;
}
}
}
//duration is finished
$cut_off_time = $each_cart->cart_abandon_time + $duration;
//.........这里部分代码省略.........