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


PHP WC_Product::get_regular_price方法代码示例

本文整理汇总了PHP中WC_Product::get_regular_price方法的典型用法代码示例。如果您正苦于以下问题:PHP WC_Product::get_regular_price方法的具体用法?PHP WC_Product::get_regular_price怎么用?PHP WC_Product::get_regular_price使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WC_Product的用法示例。


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

示例1: get_product_data

 /**
  * Get standard product data that applies to every product type
  *
  * @since 2.1
  * @param WC_Product $product
  * @return array
  */
 private function get_product_data($product)
 {
     return array('title' => $product->get_name(), 'id' => $product->get_id(), 'created_at' => $this->server->format_datetime($product->get_date_created(), false, true), 'updated_at' => $this->server->format_datetime($product->get_date_modified(), false, true), 'type' => $product->get_type(), 'status' => $product->get_status(), 'downloadable' => $product->is_downloadable(), 'virtual' => $product->is_virtual(), 'permalink' => $product->get_permalink(), 'sku' => $product->get_sku(), 'price' => wc_format_decimal($product->get_price(), 2), 'regular_price' => wc_format_decimal($product->get_regular_price(), 2), 'sale_price' => $product->get_sale_price() ? wc_format_decimal($product->get_sale_price(), 2) : null, 'price_html' => $product->get_price_html(), 'taxable' => $product->is_taxable(), 'tax_status' => $product->get_tax_status(), 'tax_class' => $product->get_tax_class(), 'managing_stock' => $product->managing_stock(), 'stock_quantity' => $product->get_stock_quantity(), 'in_stock' => $product->is_in_stock(), 'backorders_allowed' => $product->backorders_allowed(), 'backordered' => $product->is_on_backorder(), 'sold_individually' => $product->is_sold_individually(), 'purchaseable' => $product->is_purchasable(), 'featured' => $product->is_featured(), 'visible' => $product->is_visible(), 'catalog_visibility' => $product->get_catalog_visibility(), 'on_sale' => $product->is_on_sale(), 'weight' => $product->get_weight() ? wc_format_decimal($product->get_weight(), 2) : null, 'dimensions' => array('length' => $product->get_length(), 'width' => $product->get_width(), 'height' => $product->get_height(), 'unit' => get_option('woocommerce_dimension_unit')), 'shipping_required' => $product->needs_shipping(), 'shipping_taxable' => $product->is_shipping_taxable(), 'shipping_class' => $product->get_shipping_class(), 'shipping_class_id' => 0 !== $product->get_shipping_class_id() ? $product->get_shipping_class_id() : null, 'description' => apply_filters('the_content', $product->get_description()), 'short_description' => apply_filters('woocommerce_short_description', $product->get_short_description()), 'reviews_allowed' => $product->get_reviews_allowed(), 'average_rating' => wc_format_decimal($product->get_average_rating(), 2), 'rating_count' => $product->get_rating_count(), 'related_ids' => array_map('absint', array_values(wc_get_related_products($product->get_id()))), 'upsell_ids' => array_map('absint', $product->get_upsell_ids()), 'cross_sell_ids' => array_map('absint', $product->get_cross_sell_ids()), 'categories' => wc_get_object_terms($product->get_id(), 'product_cat', 'name'), 'tags' => wc_get_object_terms($product->get_id(), 'product_tag', 'name'), 'images' => $this->get_images($product), 'featured_src' => wp_get_attachment_url(get_post_thumbnail_id($product->get_id())), 'attributes' => $this->get_attributes($product), 'downloads' => $this->get_downloads($product), 'download_limit' => $product->get_download_limit(), 'download_expiry' => $product->get_download_expiry(), 'download_type' => 'standard', 'purchase_note' => apply_filters('the_content', $product->get_purchase_note()), 'total_sales' => $product->get_total_sales(), 'variations' => array(), 'parent' => array());
 }
开发者ID:woocommerce,项目名称:woocommerce,代码行数:11,代码来源:class-wc-api-products.php

示例2: woocs_product

function woocs_product($ID, $attr, $currency = true)
{
    if (class_exists('WC_Product')) {
        $product = new WC_Product($ID);
        if ($attr == 'price_tax_inc') {
            $p = round($product->get_price_including_tax(), 2);
        } elseif ($attr == 'get_price_excluding_tax') {
            $p = round($product->get_price_excluding_tax(), 2);
        } elseif ($attr == 'get_price') {
            $p = round($product->get_price(), 2);
        } elseif ($attr == 'get_sale_price') {
            $p = round($product->get_sale_price(), 2);
        } elseif ($attr == 'get_regular_price') {
            $p = round($product->get_regular_price(), 2);
        } elseif ($attr == 'get_price_html') {
            $p = strip_tags($product->get_price_html());
        } elseif ($attr == 'is_in_stock') {
            $p = $product->is_in_stock();
        }
    }
    return $p;
}
开发者ID:agalardo,项目名称:mal-mala,代码行数:22,代码来源:woocs-functions.php

示例3: 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

示例4:

 /**
  * Test updating a product.
  *
  * @since 2.7.0
  */
 function test_product_update()
 {
     $product = WC_Helper_Product::create_simple_product();
     $this->assertEquals('10', $product->get_regular_price());
     $product->set_regular_price(15);
     $product->save();
     // Reread from database
     $product = new WC_Product($product->get_id());
     $this->assertEquals('15', $product->get_regular_price());
 }
开发者ID:woocommerce,项目名称:woocommerce,代码行数:15,代码来源:data-store.php

示例5: get_base_product_price

 public function get_base_product_price($id, $price)
 {
     if (!defined('WC_RBP_SHORTCODE_PRODUCT_BASE_PRICING')) {
         define('WC_RBP_SHORTCODE_PRODUCT_BASE_PRICING', true);
     }
     $product = new WC_Product($id);
     if ($price == 'product_regular_price') {
         return $product->get_regular_price();
     }
     if ($price == 'product_selling_price') {
         return $product->get_sale_price();
     }
 }
开发者ID:7GRAFIX,项目名称:WooCommerce-Role-Based-Price,代码行数:13,代码来源:class-product-functions.php

示例6: get_composite_regular_price

 /**
  * Get min/max composite regular price.
  *
  * @param  string $min_or_max
  * @return double
  */
 public function get_composite_regular_price($min_or_max = 'min', $display = false)
 {
     if ($this->is_priced_per_product()) {
         if (!$this->is_synced()) {
             $this->sync_composite();
         }
         $price = $min_or_max === 'min' ? $this->min_composite_regular_price : $this->max_composite_regular_price;
         if ($price && $display) {
             $display_price = WC_CP()->api->get_composited_product_price($this, $this->get_base_regular_price());
             foreach ($this->price_index['regular_price'][$min_or_max] as $component_id => $product_id) {
                 $component_data = $this->get_component_data($component_id);
                 $item_qty = $component_data['optional'] === 'yes' && $min_or_max === 'min' ? 0 : $component_data['quantity_' . $min_or_max];
                 if ($item_qty) {
                     $composited_product = $this->get_composited_product($component_id, $product_id);
                     $display_price += $item_qty * $composited_product->get_regular_price($min_or_max, true);
                 }
             }
             $price = $display_price;
         }
     } else {
         $price = parent::get_regular_price();
         if ($display) {
             $price = WC_CP_Core_Compatibility::is_wc_version_gte_2_4() ? parent::get_display_price($price) : WC_CP()->api->get_composited_product_price($this, $price);
         }
     }
     return $price;
 }
开发者ID:alexbaron50,项目名称:Rockk3rs-Lab-Test,代码行数:33,代码来源:class-wc-product-composite.php

示例7: get_product_data

 /**
  * Get product data.
  *
  * @param WC_Product $product Product instance.
  * @return array
  */
 protected function get_product_data($product)
 {
     $data = array('id' => $product->get_id(), 'name' => $product->get_name(), 'slug' => $product->get_slug(), 'permalink' => $product->get_permalink(), 'date_created' => wc_rest_prepare_date_response($product->get_date_created()), 'date_modified' => wc_rest_prepare_date_response($product->get_date_modified()), 'type' => $product->get_type(), 'status' => $product->get_status(), 'featured' => $product->is_featured(), 'catalog_visibility' => $product->get_catalog_visibility(), 'description' => wpautop(do_shortcode($product->get_description())), 'short_description' => apply_filters('woocommerce_short_description', $product->get_short_description()), 'sku' => $product->get_sku(), 'price' => $product->get_price(), 'regular_price' => $product->get_regular_price(), 'sale_price' => $product->get_sale_price() ? $product->get_sale_price() : '', 'date_on_sale_from' => $product->get_date_on_sale_from() ? date('Y-m-d', $product->get_date_on_sale_from()) : '', 'date_on_sale_to' => $product->get_date_on_sale_to() ? date('Y-m-d', $product->get_date_on_sale_to()) : '', 'price_html' => $product->get_price_html(), 'on_sale' => $product->is_on_sale(), 'purchasable' => $product->is_purchasable(), 'total_sales' => $product->get_total_sales(), 'virtual' => $product->is_virtual(), 'downloadable' => $product->is_downloadable(), 'downloads' => $this->get_downloads($product), 'download_limit' => $product->get_download_limit(), 'download_expiry' => $product->get_download_expiry(), 'download_type' => 'standard', 'external_url' => $product->is_type('external') ? $product->get_product_url() : '', 'button_text' => $product->is_type('external') ? $product->get_button_text() : '', 'tax_status' => $product->get_tax_status(), 'tax_class' => $product->get_tax_class(), 'manage_stock' => $product->managing_stock(), 'stock_quantity' => $product->get_stock_quantity(), 'in_stock' => $product->is_in_stock(), 'backorders' => $product->get_backorders(), 'backorders_allowed' => $product->backorders_allowed(), 'backordered' => $product->is_on_backorder(), 'sold_individually' => $product->is_sold_individually(), 'weight' => $product->get_weight(), 'dimensions' => array('length' => $product->get_length(), 'width' => $product->get_width(), 'height' => $product->get_height()), 'shipping_required' => $product->needs_shipping(), 'shipping_taxable' => $product->is_shipping_taxable(), 'shipping_class' => $product->get_shipping_class(), 'shipping_class_id' => $product->get_shipping_class_id(), 'reviews_allowed' => $product->get_reviews_allowed(), 'average_rating' => wc_format_decimal($product->get_average_rating(), 2), 'rating_count' => $product->get_rating_count(), 'related_ids' => array_map('absint', array_values(wc_get_related_products($product->get_id()))), 'upsell_ids' => array_map('absint', $product->get_upsell_ids()), 'cross_sell_ids' => array_map('absint', $product->get_cross_sell_ids()), 'parent_id' => $product->get_parent_id(), 'purchase_note' => wpautop(do_shortcode(wp_kses_post($product->get_purchase_note()))), 'categories' => $this->get_taxonomy_terms($product), 'tags' => $this->get_taxonomy_terms($product, 'tag'), 'images' => $this->get_images($product), 'attributes' => $this->get_attributes($product), 'default_attributes' => $this->get_default_attributes($product), 'variations' => array(), 'grouped_products' => array(), 'menu_order' => $product->get_menu_order());
     return $data;
 }
开发者ID:shivapoudel,项目名称:woocommerce,代码行数:11,代码来源:class-wc-rest-products-controller.php

示例8: bulk_edit_save

 /**
  * Bulk edit.
  *
  * @param integer $post_id
  * @param WC_Product $product
  */
 public function bulk_edit_save($post_id, $product)
 {
     $old_regular_price = $product->get_regular_price();
     $old_sale_price = $product->get_sale_price();
     // Save fields
     if (!empty($_REQUEST['change_weight']) && isset($_REQUEST['_weight'])) {
         $product->set_weight(wc_clean(stripslashes($_REQUEST['_weight'])));
     }
     if (!empty($_REQUEST['change_dimensions'])) {
         if (isset($_REQUEST['_length'])) {
             $product->set_length(wc_clean(stripslashes($_REQUEST['_length'])));
         }
         if (isset($_REQUEST['_width'])) {
             $product->set_width(wc_clean(stripslashes($_REQUEST['_width'])));
         }
         if (isset($_REQUEST['_height'])) {
             $product->set_height(wc_clean(stripslashes($_REQUEST['_height'])));
         }
     }
     if (!empty($_REQUEST['_tax_status'])) {
         $product->set_tax_status(wc_clean($_REQUEST['_tax_status']));
     }
     if (!empty($_REQUEST['_tax_class'])) {
         $tax_class = wc_clean($_REQUEST['_tax_class']);
         if ('standard' == $tax_class) {
             $tax_class = '';
         }
         $product->set_tax_class($tax_class);
     }
     if (!empty($_REQUEST['_shipping_class'])) {
         $shipping_class = '_no_shipping_class' == $_REQUEST['_shipping_class'] ? '' : wc_clean($_REQUEST['_shipping_class']);
         $shipping_class_id = $data_store->get_shipping_class_id_by_slug($shipping_class);
         if ($shipping_class_id) {
             $product->set_shipping_class_id($shipping_class_id);
         }
     }
     if (!empty($_REQUEST['_visibility'])) {
         $product->set_catalog_visibility(wc_clean($_REQUEST['_visibility']));
     }
     if (!empty($_REQUEST['_featured'])) {
         $product->set_featured(stripslashes($_REQUEST['_featured']));
     }
     // Sold Individually
     if (!empty($_REQUEST['_sold_individually'])) {
         if ('yes' === $_REQUEST['_sold_individually']) {
             $product->set_sold_individually('yes');
         } else {
             $product->set_sold_individually('');
         }
     }
     // Handle price - remove dates and set to lowest
     $change_price_product_types = apply_filters('woocommerce_bulk_edit_save_price_product_types', array('simple', 'external'));
     $can_product_type_change_price = false;
     foreach ($change_price_product_types as $product_type) {
         if ($product->is_type($product_type)) {
             $can_product_type_change_price = true;
             break;
         }
     }
     if ($can_product_type_change_price) {
         $price_changed = false;
         if (!empty($_REQUEST['change_regular_price'])) {
             $change_regular_price = absint($_REQUEST['change_regular_price']);
             $regular_price = esc_attr(stripslashes($_REQUEST['_regular_price']));
             switch ($change_regular_price) {
                 case 1:
                     $new_price = $regular_price;
                     break;
                 case 2:
                     if (strstr($regular_price, '%')) {
                         $percent = str_replace('%', '', $regular_price) / 100;
                         $new_price = $old_regular_price + round($old_regular_price * $percent, wc_get_price_decimals());
                     } else {
                         $new_price = $old_regular_price + $regular_price;
                     }
                     break;
                 case 3:
                     if (strstr($regular_price, '%')) {
                         $percent = str_replace('%', '', $regular_price) / 100;
                         $new_price = max(0, $old_regular_price - round($old_regular_price * $percent, wc_get_price_decimals()));
                     } else {
                         $new_price = max(0, $old_regular_price - $regular_price);
                     }
                     break;
                 default:
                     break;
             }
             if (isset($new_price) && $new_price != $old_regular_price) {
                 $price_changed = true;
                 $new_price = round($new_price, wc_get_price_decimals());
                 $product->set_regular_price($new_price);
             }
         }
         if (!empty($_REQUEST['change_sale_price'])) {
//.........这里部分代码省略.........
开发者ID:shivapoudel,项目名称:woocommerce,代码行数:101,代码来源:class-wc-admin-post-types.php

示例9: get_ticket

 /**
  * Gets an individual ticket
  *
  * @param $event_id
  * @param $ticket_id
  *
  * @return null|Tribe__Events__Tickets__Ticket_Object
  */
 public function get_ticket($event_id, $ticket_id)
 {
     if (class_exists('WC_Product_Simple')) {
         $product = new WC_Product_Simple($ticket_id);
     } else {
         $product = new WC_Product($ticket_id);
     }
     if (!$product) {
         return null;
     }
     $return = new Tribe__Events__Tickets__Ticket_Object();
     $product_data = $product->get_post_data();
     $qty = get_post_meta($ticket_id, 'total_sales', true);
     $return->description = $product_data->post_excerpt;
     $return->frontend_link = get_permalink($ticket_id);
     $return->ID = $ticket_id;
     $return->name = $product->get_title();
     $return->price = $product->get_price();
     $return->regular_price = $product->get_regular_price();
     $return->on_sale = (bool) $product->is_on_sale();
     $return->provider_class = get_class($this);
     $return->admin_link = admin_url(sprintf(get_post_type_object($product_data->post_type)->_edit_link . '&action=edit', $ticket_id));
     $return->stock = $product->get_stock_quantity();
     $return->start_date = get_post_meta($ticket_id, '_ticket_start_date', true);
     $return->end_date = get_post_meta($ticket_id, '_ticket_end_date', true);
     $return->qty_sold = $qty ? $qty : 0;
     $return->qty_pending = $qty ? $this->count_incomplete_order_items($ticket_id) : 0;
     $return->purchase_limit = get_post_meta($ticket_id, '_ticket_purchase_limit', true);
     if (empty($return->purchase_limit) && 0 !== (int) $return->purchase_limit) {
         /**
          * Filter the default purchase limit for the ticket
          *
          * @var int
          *
          * @return int
          */
         $return->purchase_limit = apply_filters('tribe_tickets_default_purchase_limit', 0);
     }
     return apply_filters('wootickets_get_ticket', $return, $event_id, $ticket_id);
 }
开发者ID:TakenCdosG,项目名称:chefs,代码行数:48,代码来源:Main.php

示例10: empty

 /**
  * Filter get_price() calls for bundled products to include discounts.
  *
  * @param  double       $price      unmodified price
  * @param  WC_Product   $product    the bundled product
  * @return double                   modified price
  */
 function get_price($price, $product)
 {
     if ($product->id !== $this->product->id || $price === '') {
         return $price;
     }
     if (!$this->is_priced_per_product()) {
         return 0;
     }
     if (apply_filters('woocommerce_bundled_item_discount_from_regular', true, $this)) {
         $regular_price = $product->get_regular_price();
     } else {
         $regular_price = $price;
     }
     $discount = $this->get_discount();
     $bundled_item_price = empty($discount) ? (double) $price : round((double) $regular_price * (100 - $discount) / 100, wc_bundles_get_price_decimals());
     $product->bundled_item_price = $bundled_item_price;
     return apply_filters('woocommerce_bundled_item_price', $bundled_item_price, $product, $discount);
 }
开发者ID:puppy09,项目名称:madC,代码行数:25,代码来源:class-wc-bundled-item.php

示例11: get_ticket

 /**
  * Gets an individual ticket
  *
  * @param $unused_event_id
  * @param $ticket_id
  *
  * @return null|Tribe__Events__Tickets__Ticket_Object
  */
 public function get_ticket($unused_event_id, $ticket_id)
 {
     if (class_exists('WC_Product_Simple')) {
         $product = new WC_Product_Simple($ticket_id);
     } else {
         $product = new WC_Product($ticket_id);
     }
     if (!$product) {
         return null;
     }
     $return = new Tribe__Events__Tickets__Ticket_Object();
     $product_data = $product->get_post_data();
     $qty = get_post_meta($ticket_id, 'total_sales', true);
     $return->description = $product_data->post_excerpt;
     $return->frontend_link = get_permalink($ticket_id);
     $return->ID = $ticket_id;
     $return->name = $product->get_title();
     $return->price = $product->get_price();
     $return->regular_price = $product->get_regular_price();
     $return->on_sale = (bool) $product->is_on_sale();
     $return->provider_class = get_class($this);
     $return->admin_link = admin_url(sprintf(get_post_type_object($product_data->post_type)->_edit_link . '&action=edit', $ticket_id));
     $return->stock = $product->get_stock_quantity();
     $return->start_date = get_post_meta($ticket_id, '_ticket_start_date', true);
     $return->end_date = get_post_meta($ticket_id, '_ticket_end_date', true);
     $return->qty_sold = $qty ? $qty : 0;
     $return->qty_pending = $qty ? $this->count_incomplete_order_items($ticket_id) : 0;
     return $return;
 }
开发者ID:pellio11,项目名称:ns-select-project,代码行数:37,代码来源:Main.php

示例12: get_product_from_post


//.........这里部分代码省略.........
                 }
             }
         }
     } catch (Exception $e) {
     }
     $send_product = array('product_id' => $product->id, 'currency' => get_woocommerce_currency(), 'price' => $product->get_price(), 'url' => get_permalink($product->id), 'thumbnail_url' => $thumbnail, 'action' => 'insert', 'description' => $product->get_post_data()->post_content, 'short_description' => $product->get_post_data()->post_excerpt, 'name' => $product->get_title(), 'sku' => $product->get_sku(), 'categories' => $product->get_categories(), 'tag' => $product_tags, 'store_id' => get_current_blog_id(), 'identifier' => (string) $product->id, 'product_brand' => $product_brands, 'taxonomies' => $taxonomies, 'acf_fields' => $acf_fields, 'sellable' => $product->is_purchasable(), 'visibility' => $product->is_visible(), 'stock_quantity' => $product->get_stock_quantity(), 'is_managing_stock' => $product->managing_stock(), 'is_backorders_allowed' => $product->backorders_allowed(), 'is_purchasable' => $product->is_purchasable(), 'is_in_stock' => $product->is_in_stock(), 'product_status' => get_post_status($post_id));
     try {
         $variable = new WC_Product_Variable($post_id);
         $variations = $variable->get_available_variations();
         $variations_sku = '';
         if (!empty($variations)) {
             foreach ($variations as $variation) {
                 if ($product->get_sku() != $variation['sku']) {
                     $variations_sku .= $variation['sku'] . ' ';
                 }
             }
         }
         $send_product['variations_sku'] = $variations_sku;
         $all_attributes = $product->get_attributes();
         $attributes = array();
         if (!empty($all_attributes)) {
             foreach ($all_attributes as $attr_mame => $value) {
                 if ($all_attributes[$attr_mame]['is_taxonomy']) {
                     if (!$woocommerce_ver_below_2_1) {
                         $attributes[$attr_mame] = wc_get_product_terms($post_id, $attr_mame, array('fields' => 'names'));
                     } else {
                         $attributes[$attr_mame] = woocommerce_get_product_terms($post_id, $attr_mame, 'names');
                     }
                 } else {
                     $attributes[$attr_mame] = $product->get_attribute($attr_mame);
                 }
             }
         }
         $send_product['attributes'] = $attributes;
         $send_product['total_variable_stock'] = $variable->get_total_stock();
         try {
             if (version_compare(WOOCOMMERCE_VERSION, '2.2', '>=')) {
                 if (function_exists('wc_get_product')) {
                     $original_product = wc_get_product($product->id);
                     if (is_object($original_product)) {
                         $send_product['visibility'] = $original_product->is_visible();
                         $send_product['product_type'] = $original_product->product_type;
                     }
                 }
             } else {
                 if (function_exists('get_product')) {
                     $original_product = get_product($product->id);
                     if (is_object($original_product)) {
                         $send_product['visibility'] = $original_product->is_visible();
                         $send_product['product_type'] = $original_product->product_type;
                     }
                 }
             }
         } catch (Exception $e) {
         }
     } catch (Exception $e) {
         $err_msg = "exception raised in attributes";
         self::send_error_report($err_msg);
     }
     if (!$woocommerce_ver_below_2_1) {
         try {
             $send_product['price_compare_at_price'] = $product->get_regular_price();
             $send_product['price_min'] = $variable->get_variation_price('min');
             $send_product['price_max'] = $variable->get_variation_price('max');
             $send_product['price_min_compare_at_price'] = $variable->get_variation_regular_price('min');
             $send_product['price_max_compare_at_price'] = $variable->get_variation_regular_price('max');
         } catch (Exception $e) {
             $send_product['price_compare_at_price'] = null;
             $send_product['price_min'] = null;
             $send_product['price_max'] = null;
             $send_product['price_min_compare_at_price'] = null;
             $send_product['price_max_compare_at_price'] = null;
         }
     } else {
         $send_product['price_compare_at_price'] = null;
         $send_product['price_min'] = null;
         $send_product['price_max'] = null;
         $send_product['price_min_compare_at_price'] = null;
         $send_product['price_max_compare_at_price'] = null;
     }
     $send_product['description'] = self::content_filter_shortcode_with_content($send_product['description']);
     $send_product['short_description'] = self::content_filter_shortcode_with_content($send_product['short_description']);
     $send_product['description'] = self::content_filter_shortcode($send_product['description']);
     $send_product['short_description'] = self::content_filter_shortcode($send_product['short_description']);
     try {
         if (defined('ICL_SITEPRESS_VERSION') && is_plugin_active('woocommerce-multilingual/wpml-woocommerce.php') && function_exists('wpml_get_language_information')) {
             if (version_compare(ICL_SITEPRESS_VERSION, '3.2', '>=')) {
                 $language_info = apply_filters('wpml_post_language_details', NULL, $post_id);
             } else {
                 $language_info = wpml_get_language_information($post_id);
             }
             if ($language_info && is_array($language_info) && array_key_exists('locale', $language_info)) {
                 // WP_Error could be returned from wpml_get_language_information(...)
                 $send_product['lang'] = $language_info['locale'];
             }
         }
     } catch (Exception $e) {
     }
     return $send_product;
 }
开发者ID:booklein,项目名称:wpbookle,代码行数:101,代码来源:wcis_plugin.php

示例13: get_ticket

 /**
  * Gets an individual ticket
  *
  * @param $event_id
  * @param $ticket_id
  *
  * @return null|Tribe__Tickets__Ticket_Object
  */
 public function get_ticket($event_id, $ticket_id)
 {
     if (class_exists('WC_Product_Simple')) {
         $product = new WC_Product_Simple($ticket_id);
     } else {
         $product = new WC_Product($ticket_id);
     }
     if (!$product) {
         return null;
     }
     $return = new Tribe__Tickets__Ticket_Object();
     $product_data = $product->get_post_data();
     $qty = get_post_meta($ticket_id, 'total_sales', true);
     $return->description = $product_data->post_excerpt;
     $return->frontend_link = get_permalink($ticket_id);
     $return->ID = $ticket_id;
     $return->name = $product->get_title();
     $return->price = $product->get_price();
     $return->regular_price = $product->get_regular_price();
     $return->on_sale = (bool) $product->is_on_sale();
     $return->provider_class = get_class($this);
     $return->admin_link = admin_url(sprintf(get_post_type_object($product_data->post_type)->_edit_link . '&action=edit', $ticket_id));
     $return->start_date = get_post_meta($ticket_id, '_ticket_start_date', true);
     $return->end_date = get_post_meta($ticket_id, '_ticket_end_date', true);
     $return->purchase_limit = get_post_meta($ticket_id, '_ticket_purchase_limit', true);
     $complete_totals = $this->count_order_items_by_status($ticket_id, 'complete');
     $pending_totals = $this->count_order_items_by_status($ticket_id, 'incomplete');
     $qty = $qty ? $qty : 0;
     $pending = $pending_totals['total'] ? $pending_totals['total'] : 0;
     // if any orders transitioned from complete back to one of the incomplete states, their quantities
     // were already recorded in total_sales and we have to deduct them from there so they aren't
     // double counted
     $qty -= $pending_totals['recorded_sales'];
     // let's calculate the stock based on the product stock minus the quantity purchased minus the
     // pending purchases
     $stock = $product->get_stock_quantity() - $qty - $pending;
     // if any orders have reduced the stock of an order (check and cash on delivery payments do this, for example)
     // we need to re-inflate the stock by that amount
     $stock += $pending_totals['reduced_stock'];
     $stock += $complete_totals['reduced_stock'];
     $return->manage_stock($product->managing_stock());
     $return->stock($stock);
     $return->qty_sold($qty);
     $return->qty_pending($pending);
     $return->qty_cancelled($this->get_cancelled($ticket_id));
     if (empty($return->purchase_limit) && 0 !== (int) $return->purchase_limit) {
         /**
          * Filter the default purchase limit for the ticket
          *
          * @var int
          *
          * @return int
          */
         $return->purchase_limit = apply_filters('tribe_tickets_default_purchase_limit', 0);
     }
     return apply_filters('wootickets_get_ticket', $return, $event_id, $ticket_id);
 }
开发者ID:jamestrevorlees,项目名称:odd-web-v1.00,代码行数:65,代码来源:Main.php

示例14: get_regular_price

 /**
  * Overrides get_regular_price to return base price in static price mode.
  *
  * @return double
  */
 public function get_regular_price()
 {
     if ($this->is_priced_per_product()) {
         return apply_filters('woocommerce_composite_get_regular_price', $this->get_base_regular_price(), $this);
     } else {
         return parent::get_regular_price();
     }
 }
开发者ID:ajay786singh,项目名称:viriditas-1,代码行数:13,代码来源:class-wc-product-composite.php

示例15: get_product_data

 /**
  * Get standard product data that applies to every product type
  *
  * @since 2.1
  * @param WC_Product $product
  * @return WC_Product
  */
 private function get_product_data($product, $fields = null)
 {
     if ($fields) {
         $field_list = explode(',', $fields);
     }
     $product_data = array();
     if (!$fields || $fields && in_array('title', $field_list)) {
         $product_data['title'] = $product->get_title();
     }
     if (!$fields || $fields && in_array('id', $field_list)) {
         $product_data['id'] = (int) $product->is_type('variation') ? $product->get_variation_id() : $product->id;
     }
     if (!$fields || $fields && in_array('created_at', $field_list)) {
         $product_data['created_at'] = $this->server->format_datetime($product->get_post_data()->post_date_gmt);
     }
     if (!$fields || $fields && in_array('updated_at', $field_list)) {
         $product_data['updated_at'] = $this->server->format_datetime($product->get_post_data()->post_modified_gmt);
     }
     if (!$fields || $fields && in_array('type', $field_list)) {
         $product_data['type'] = $product->product_type;
     }
     if (!$fields || $fields && in_array('status', $field_list)) {
         $product_data['status'] = $product->get_post_data()->post_status;
     }
     if (!$fields || $fields && in_array('downloadable', $field_list)) {
         $product_data['downloadable'] = $product->is_downloadable();
     }
     if (!$fields || $fields && in_array('virtual', $field_list)) {
         $product_data['virtual'] = $product->is_virtual();
     }
     if (!$fields || $fields && in_array('permalink', $field_list)) {
         $product_data['permalink'] = $product->get_permalink();
     }
     if (!$fields || $fields && in_array('sku', $field_list)) {
         $product_data['sku'] = $product->get_sku();
     }
     if (!$fields || $fields && in_array('price', $field_list)) {
         $product_data['price'] = $product->get_price();
     }
     if (!$fields || $fields && in_array('regular_price', $field_list)) {
         $product_data['regular_price'] = $product->get_regular_price();
     }
     if (!$fields || $fields && in_array('sale_price', $field_list)) {
         $product_data['sale_price'] = $product->get_sale_price() ? $product->get_sale_price() : null;
     }
     if (!$fields || $fields && in_array('price_html', $field_list)) {
         $product_data['price_html'] = $product->get_price_html();
     }
     if (!$fields || $fields && in_array('taxable', $field_list)) {
         $product_data['taxable'] = $product->is_taxable();
     }
     if (!$fields || $fields && in_array('tax_status', $field_list)) {
         $product_data['tax_status'] = $product->get_tax_status();
     }
     if (!$fields || $fields && in_array('tax_class', $field_list)) {
         $product_data['tax_class'] = $product->get_tax_class();
     }
     if (!$fields || $fields && in_array('managing_stock', $field_list)) {
         $product_data['managing_stock'] = $product->managing_stock();
     }
     if (!$fields || $fields && in_array('stock_quantity', $field_list)) {
         $product_data['stock_quantity'] = $product->get_stock_quantity();
     }
     if (!$fields || $fields && in_array('in_stock', $field_list)) {
         $product_data['in_stock'] = $product->is_in_stock();
     }
     if (!$fields || $fields && in_array('backorders_allowed', $field_list)) {
         $product_data['backorders_allowed'] = $product->backorders_allowed();
     }
     if (!$fields || $fields && in_array('backordered', $field_list)) {
         $product_data['backordered'] = $product->is_on_backorder();
     }
     if (!$fields || $fields && in_array('sold_individually', $field_list)) {
         $product_data['sold_individually'] = $product->is_sold_individually();
     }
     if (!$fields || $fields && in_array('purchaseable', $field_list)) {
         $product_data['purchaseable'] = $product->is_purchasable();
     }
     if (!$fields || $fields && in_array('featured', $field_list)) {
         $product_data['featured'] = $product->is_featured();
     }
     if (!$fields || $fields && in_array('visible', $field_list)) {
         $product_data['visible'] = $product->is_visible();
     }
     if (!$fields || $fields && in_array('catalog_visibility', $field_list)) {
         $product_data['catalog_visibility'] = $product->visibility;
     }
     if (!$fields || $fields && in_array('on_sale', $field_list)) {
         $product_data['on_sale'] = $product->is_on_sale();
     }
     if (!$fields || $fields && in_array('product_url', $field_list)) {
         $product_data['product_url'] = $product->is_type('external') ? $product->get_product_url() : '';
     }
//.........这里部分代码省略.........
开发者ID:Nils-Fredrik,项目名称:woocommerce,代码行数:101,代码来源:class-wc-api-products.php


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