本文整理汇总了PHP中WC_Product::is_on_sale方法的典型用法代码示例。如果您正苦于以下问题:PHP WC_Product::is_on_sale方法的具体用法?PHP WC_Product::is_on_sale怎么用?PHP WC_Product::is_on_sale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WC_Product
的用法示例。
在下文中一共展示了WC_Product::is_on_sale方法的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());
}
示例2: 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) : '';
}
示例3: hocwp_wc_is_sale
function hocwp_wc_is_sale($post_id = null)
{
$post_id = hocwp_return_post($post_id, 'id');
if (hocwp_id_number_valid($post_id)) {
$pro = new WC_Product($post_id);
return $pro->is_on_sale();
}
global $product;
return $product->is_on_sale();
}
示例4: 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;
}
示例5: array
//.........这里部分代码省略.........
}
$front_edit_reverse = array("asc" => __('Bottom to Top', "ts_visual_composer_extend"), "desc" => __('Top to Bottom', "ts_visual_composer_extend"));
foreach ($front_edit_reverse as $key => $value) {
if ($key == $sort_order) {
echo '<div>' . __("Initial Order", "ts_visual_composer_extend") . ': ' . $value . '</div>';
}
}
echo '<div>' . __("Show Filter Button", "ts_visual_composer_extend") . ': ' . $filter_menu . '</div>';
echo '<div>' . __("Show Layout Button", "ts_visual_composer_extend") . ': ' . $layout_menu . '</div>';
echo '<div>' . __("Show Sort Criterion Button", "ts_visual_composer_extend") . ': ' . $sort_menu . '</div>';
echo '<div>' . __("Show Directions Buttons", "ts_visual_composer_extend") . ': ' . $directions_menu . '</div>';
echo '</div>';
} else {
$opening .= '<div id="' . $posts_container_id . '" class="ts-isotope-posts-grid-parent ' . ($layout == 'spineTimeline' ? 'ts-timeline ' : 'ts-postsgrid ') . 'ts-timeline-' . $sort_order . ' ts-posts-timeline ' . $isotope_posts_list_class . ' ' . $css_class . '" style="margin-top: ' . $margin_top . 'px; margin-bottom: ' . $margin_bottom . ';" data-lazy="' . $posts_lazy . '" data-count="' . $posts_limit . '" data-ajax="' . $posts_ajax . '" data-trigger="' . $posts_trigger . '" data-column="' . $column_width . '" data-layout="' . $layout . '" data-sort="' . $sort_by . '" data-order="' . $sort_order . '" data-break="' . $layout_break . '" data-type="' . $post_type . '">';
// Create Individual Post Output
$postCounter = 0;
$postCategories = array();
$categoriesCount = 0;
if (post_type_exists($post_type) && $loop->have_posts()) {
$products .= '<div class="ts-timeline-content">';
$products .= '<ul id="ts-isotope-posts-grid-' . $postsgrid_random . '" class="ts-isotope-posts-grid ts-timeline-list" data-layout="' . $layout . '" data-key="' . $postsgrid_random . '">';
while ($loop->have_posts()) {
$loop->the_post();
$postCounter++;
$product_id = get_the_ID();
$product_title = get_the_title($product_id);
$post = get_post($product_id);
$product = new WC_Product($product_id);
$attachment_ids = $product->get_gallery_attachment_ids();
$price = $product->get_price_html();
$product_sku = $product->get_sku();
$attributes = $product->get_attributes();
$stock = $product->is_in_stock() ? 'true' : 'false';
$onsale = $product->is_on_sale() ? 'true' : 'false';
// Rating Settings
$rating_html = $product->get_rating_html();
$rating = $product->get_average_rating();
if ($rating == '') {
$rating = 0;
}
if ($rating_quarter == "true") {
$rating_value = floor($rating * 4) / 4;
} else {
$rating_value = $rating;
}
$rating_value = number_format($rating_value, 2, $caption_digits, '');
if ($rating_rtl == "false") {
$rating_width = $rating_value / $rating_maximum * 100;
} else {
$rating_width = 100 - $rating_value / $rating_maximum * 100;
}
if ($rating_symbol == "other") {
if ($rating_icon == "ts-ecommerce-starfull1") {
$rating_class = 'ts-rating-stars-star1';
} else {
if ($rating_icon == "ts-ecommerce-starfull2") {
$rating_class = 'ts-rating-stars-star2';
} else {
if ($rating_icon == "ts-ecommerce-starfull3") {
$rating_class = 'ts-rating-stars-star3';
} else {
if ($rating_icon == "ts-ecommerce-starfull4") {
$rating_class = 'ts-rating-stars-star4';
} else {
if ($rating_icon == "ts-ecommerce-heartfull") {
$rating_class = 'ts-rating-stars-heart1';
示例6: 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);
}
示例7: WooComposer_Loop_style04
//.........这里部分代码省略.........
$test = '';
if (vc_is_inline()) {
$test = "wcmp_vc_inline";
}
if ($product_animation == '') {
$product_animation = 'no-animation';
} else {
$style .= 'opacity:1;';
}
if ($element == "grid") {
$class = 'vc_span' . $columns . ' ';
}
$output .= '<div class="woocomposer ' . $test . '" data-columns="' . $col . '">';
$query = new WP_Query($args);
if ($query->have_posts()) {
while ($query->have_posts()) {
$query->the_post();
$product_id = get_the_ID();
$uid = uniqid();
$output .= '<div id="product-' . $uid . '" style="' . $style . '" class="' . $class . ' wpb_column column_container wooproduct" data-animation="animated ' . $product_animation . '">';
if ($element == 'carousel') {
$output .= '<div class="wcmp-carousel-item">';
}
$product_title = get_the_title($product_id);
$post = get_post($product_id);
$product_desc = get_post($product_id)->post_excerpt;
$product_img = wp_get_attachment_image_src(get_post_thumbnail_id($product_id), $image_size);
$product = new WC_Product($product_id);
$attachment_ids = $product->get_gallery_attachment_ids();
$price = $product->get_price_html();
$rating = $product->get_rating_html();
$attributes = $product->get_attributes();
$stock = $product->is_in_stock() ? 'InStock' : 'OutOfStock';
if ($product->is_on_sale()) {
$on_sale = apply_filters('woocommerce_sale_flash', $label_on_sale, $post, $product);
} else {
$on_sale = '';
}
if ($quick_view_style == "expandable") {
$quick_view_class = 'quick-view-loop';
} else {
$quick_view_class = 'quick-view-loop-popup';
}
$cat_count = sizeof(get_the_terms($product_id, 'product_cat'));
$tag_count = sizeof(get_the_terms($product_id, 'product_tag'));
$categories = $product->get_categories(', ', '<span class="posted_in">' . _n('', '', $cat_count, 'woocommerce') . ' ', '.</span>');
$tags = $product->get_tags(', ', '<span class="tagged_as">' . _n('', '', $tag_count, 'woocommerce') . ' ', '.</span>');
$output .= "\n" . '<div class="wcmp-product woocommerce wcmp-' . $product_style . ' ' . $img_animate . '" style="' . $border . ' ' . $desc_style . '">';
$output .= "\n\t" . '<div class="wcmp-product-image">';
if (empty($attachment_ids) && count($attachment_ids) > 1 && $product_img_disp == "carousel") {
$uniqid = uniqid();
$output .= '<div class="wcmp-single-image-carousel carousel-in-loop">';
$product_img = wp_get_attachment_image_src(get_post_thumbnail_id($product_id), $image_size);
if ($lazy_images == "enable") {
$src = plugins_url('../assets/img/loader.gif', __FILE__);
} else {
$src = $product_img[0];
}
$output .= '<div><div class="wcmp-image"><img class="wcmp-img" src="' . $src . '" data-src="' . $product_img[0] . '"/></div></div>';
foreach ($attachment_ids as $attachment_id) {
$product_img = wp_get_attachment_image_src($attachment_id, $image_size);
if ($lazy_images == "enable") {
$src = plugins_url('../assets/img/loader.gif', __FILE__);
} else {
$src = $product_img[0];
}
示例8: array
global $product;
?>
<?php
$woolink = $product->product_type == 'external' ? $product->add_to_cart_url() : get_post_permalink(get_the_ID());
$term_ids = wp_get_post_terms(get_the_ID(), 'product_tag', array("fields" => "ids"));
if (!empty($term_ids)) {
$term_brand = $term_ids[0];
$term_brand_image = get_option("taxonomy_term_{$term_ids['0']}");
} else {
$term_brand_image = '';
}
?>
<div class="rehub_feat_block table_view_block"><a name="woo-link-list"></a>
<?php
if ($product->is_on_sale()) {
?>
<div class="vip_corner"><span class="vip_badge sale_badge">Sale!</span></div><?php
}
?>
<div class="block_with_coupon">
<div class="offer_thumb">
<a href="<?php
echo $woolink;
?>
" target="_blank"><?php
wpsm_thumb('med_thumbs');
?>
</a>
</div>
示例9: 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);
}
示例10: woo_products_carousel_func
//.........这里部分代码省略.........
$product = new WC_Product(get_the_ID());
if ($style == 'style2') {
$col = 'col-lg-4 col-md-4 col-sm-4 col-xs-12 double-product';
} elseif ($style == 'style1') {
$col = 'col-lg-3 col-md-3 col-sm-3 col-xs-12 double-product';
} elseif ($style == 'style3') {
$col = 'product product-mini col-sm-2 col-md-2';
}
?>
<?php
if ($double_product == 'yes') {
if (++$j % 2 == 0) {
echo '<div class="' . sanitize_html_classes($col) . '">';
}
} else {
echo '<div class="' . sanitize_html_classes($col) . '">';
}
?>
<?php
if ($style == 'style3') {
$product_class = '';
} else {
$product_class = 'product rotation';
}
?>
<div class="<?php
echo sanitize_html_classes($product_class);
?>
">
<div class="default">
<?php
if ($product->is_on_sale()) {
?>
<?php
echo apply_filters('woocommerce_sale_flash', '<span class="onsale">' . __('Sale!', 'woocommerce') . '</span>', $post, $product);
?>
<?php
}
?>
<a href="<?php
echo esc_url(get_the_permalink());
?>
" class="product-image">
<?php
echo get_the_post_thumbnail($post->ID, 'shop_catalog');
?>
</a>
<div class="product-description">
<div class="vertical">
<h3 class="product-name">
<a href="<?php
echo esc_url(get_the_permalink());
?>
" class="xv_product_title"><?php
the_title();
?>
</a>
</h3>
<div class="price">
<?php
echo $product->get_price_html();
?>
</div>
</div>
示例11: extract
//.........这里部分代码省略.........
$output .= '<div id="' . $woo_slider_id . '-container" class="ts-woocommerce-slider-container">';
// Add Progressbar
if ($auto_play == "true" && $show_bar == "true" && $frontend_edit == "false") {
$output .= '<div id="ts-owlslider-progressbar-' . $woo_random . '" class="ts-owlslider-progressbar-holder" style=""><div class="ts-owlslider-progressbar" style="background: ' . $bar_color . '; height: 100%; width: 0%;"></div></div>';
}
// Add Navigation Controls
if ($frontend_edit == "false") {
$output .= '<div id="ts-owlslider-controls-' . $woo_random . '" class="ts-owlslider-controls" style="' . ($auto_play == "true" || $show_navigation == "true" ? "display: block;" : "display: none;") . '">';
$output .= '<div id="ts-owlslider-controls-next-' . $woo_random . '" style="' . ($show_navigation == "true" ? "display: block;" : "display: none;") . '" class="ts-owlslider-controls-next"><span class="ts-ecommerce-arrowright5"></span></div>';
$output .= '<div id="ts-owlslider-controls-prev-' . $woo_random . '" style="' . ($show_navigation == "true" ? "display: block;" : "display: none;") . '" class="ts-owlslider-controls-prev"><span class="ts-ecommerce-arrowleft5"></span></div>';
if ($auto_play == "true") {
$output .= '<div id="ts-owlslider-controls-play-' . $woo_random . '" class="ts-owlslider-controls-play active"><span class="ts-ecommerce-pause"></span></div>';
}
$output .= '</div>';
}
// Front-Edit Message
if ($frontend_edit == "true") {
$output .= $slider_message;
}
// Add Slider
$output .= '<div id="' . $woo_slider_id . '" class="' . $css_class . '" style="margin-top: ' . $margin_top . 'px; margin-bottom: ' . $margin_bottom . 'px;" data-id="' . $woo_random . '" data-items="' . $products_slide . '" data-breakpointscustom="' . $breakpoints_custom . '" data-breakpointitems="' . $breakpoints_items . '" data-rtl="' . $page_rtl . '" data-loop="' . $items_loop . '" data-navigation="' . $show_navigation . '" data-dots="' . $show_dots . '" data-mobile="' . $animation_mobile . '" data-animationin="' . $animation_in . '" data-animationout="' . $animation_out . '" data-height="' . $auto_height . '" data-play="' . $auto_play . '" data-bar="' . $show_bar . '" data-color="' . $bar_color . '" data-speed="' . $show_speed . '" data-hover="' . $stop_hover . '">';
if ($loop->have_posts()) {
while ($loop->have_posts()) {
$loop->the_post();
$product_id = get_the_ID();
$product_title = get_the_title($product_id);
$post = get_post($product_id);
$product = new WC_Product($product_id);
$attachment_ids = $product->get_gallery_attachment_ids();
$price = $product->get_price_html();
$product_sku = $product->get_sku();
$attributes = $product->get_attributes();
$stock = $product->is_in_stock() ? 'true' : 'false';
$onsale = $product->is_on_sale() ? 'true' : 'false';
// Rating Settings
$rating_html = $product->get_rating_html();
$rating = $product->get_average_rating();
if ($rating == '') {
$rating = 0;
}
if ($rating_quarter == "true") {
$rating_value = floor($rating * 4) / 4;
} else {
$rating_value = $rating;
}
$rating_value = number_format($rating_value, 2, $caption_digits, '');
if ($rating_rtl == "false") {
$rating_width = $rating_value / $rating_maximum * 100;
} else {
$rating_width = 100 - $rating_value / $rating_maximum * 100;
}
if ($rating_symbol == "other") {
if ($rating_icon == "ts-ecommerce-starfull1") {
$rating_class = 'ts-rating-stars-star1';
} else {
if ($rating_icon == "ts-ecommerce-starfull2") {
$rating_class = 'ts-rating-stars-star2';
} else {
if ($rating_icon == "ts-ecommerce-starfull3") {
$rating_class = 'ts-rating-stars-star3';
} else {
if ($rating_icon == "ts-ecommerce-starfull4") {
$rating_class = 'ts-rating-stars-star4';
} else {
if ($rating_icon == "ts-ecommerce-heartfull") {
$rating_class = 'ts-rating-stars-heart1';
示例12: 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() : '';
}
//.........这里部分代码省略.........
示例13: extract
//.........这里部分代码省略.........
data-play="ts-newsticker-controls-play-' . $woo_random . '"
data-stop="ts-newsticker-controls-stop-' . $woo_random . '">';
$output .= '<div class="ts-newsticker-elements-frame ' . $newsticker_elements . ' ' . $ticker_border_radius . '" style="">';
// Add Navigation Controls
$output .= '<div id="ts-newsticker-controls-' . $woo_random . '" class="ts-newsticker-controls" style="' . ($ticker_controls == "true" ? "display: block;" : "display: none;") . ' ' . $newsticker_controls . '">';
$output .= '<div id="ts-newsticker-controls-next-' . $woo_random . '" style="' . ($ticker_controls == "true" ? "display: block;" : "display: none;") . '" class="ts-newsticker-controls-next"><span class="ts-ecommerce-arrowright5"></span></div>';
$output .= '<div id="ts-newsticker-controls-prev-' . $woo_random . '" style="' . ($ticker_controls == "true" ? "display: block;" : "display: none;") . '" class="ts-newsticker-controls-prev"><span class="ts-ecommerce-arrowleft5"></span></div>';
$output .= '<div id="ts-newsticker-controls-stop-' . $woo_random . '" class="ts-newsticker-controls-play" style="' . ($ticker_auto == "true" ? "display: block;" : "display: none;") . '"><span class="ts-ecommerce-pause"></span></div>';
$output .= '<div id="ts-newsticker-controls-play-' . $woo_random . '" class="ts-newsticker-controls-play" style="' . ($ticker_auto == "true" ? "display: none;" : "display: block;") . '"><span class="ts-ecommerce-play"></span></div>';
$output .= '</div>';
if ($ticker_side == "left" && $ticker_title == "true") {
$output .= '<div id="ts-newsticker-header-' . $woo_random . '" class="header ' . $ticker_border_radius . '" style="background: ' . $ticker_background . '; color: ' . $ticker_color . '; left: 0;">';
if ($ticker_icon != '' && $ticker_icon != 'transparent' && $ticker_symbol == "true") {
$output .= '<i class="ts-font-icon ' . $ticker_icon . '" style="color: ' . $ticker_paint . '"></i>';
}
$output .= '<span>' . $ticker_header . '</span>';
$output .= '</div>';
}
$output .= '<ul id="ts-newsticker-ticker-' . $woo_random . '" class="newsticker ' . $ticker_border_radius . '" style="' . $newsticker_header . '">';
while ($loop->have_posts()) {
$loop->the_post();
$postCounter++;
if ($postCounter < $posts_limit + 1) {
$postAttributes = 'data-full="' . get_post_time($date_format) . '" data-time="' . get_post_time($time_format) . '" data-author="' . get_the_author() . '" data-date="' . get_post_time('U') . '" data-modified="' . get_the_modified_time('U') . '" data-title="' . get_the_title() . '" data-comments="' . get_comments_number() . '" data-id="' . get_the_ID() . '"';
$product_id = get_the_ID();
$product_title = get_the_title($product_id);
$post = get_post($product_id);
$product = new WC_Product($product_id);
$attachment_ids = $product->get_gallery_attachment_ids();
$price = $product->get_price_html();
$product_sku = $product->get_sku();
$attributes = $product->get_attributes();
$stock = $product->is_in_stock() ? 'true' : 'false';
$onsale = $product->is_on_sale() ? 'true' : 'false';
// Rating Settings
$rating_html = $product->get_rating_html();
$rating = $product->get_average_rating();
if ($rating == '') {
$rating = 0;
}
if ($rating_quarter == "true") {
$rating_value = floor($rating * 4) / 4;
} else {
$rating_value = $rating;
}
$rating_value = number_format($rating_value, 2, $caption_digits, '');
if ($rating_rtl == "false") {
$rating_width = $rating_value / $rating_maximum * 100;
} else {
$rating_width = 100 - $rating_value / $rating_maximum * 100;
}
if ($rating_symbol == "other") {
if ($rating_icon == "ts-ecommerce-starfull1") {
$rating_class = 'ts-rating-stars-star1';
} else {
if ($rating_icon == "ts-ecommerce-starfull2") {
$rating_class = 'ts-rating-stars-star2';
} else {
if ($rating_icon == "ts-ecommerce-starfull3") {
$rating_class = 'ts-rating-stars-star3';
} else {
if ($rating_icon == "ts-ecommerce-starfull4") {
$rating_class = 'ts-rating-stars-star4';
} else {
if ($rating_icon == "ts-ecommerce-heartfull") {
$rating_class = 'ts-rating-stars-heart1';
示例14: foreach
function is_on_sale()
{
if ($this->per_product_pricing_active && !empty($this->bundled_item_ids)) {
$is_on_sale = false;
foreach ($this->bundled_item_ids as $bundled_item_id) {
// remove suffix
$sep = explode('_', $bundled_item_id);
$product_id = $sep[0];
if ($this->is_wc_v2) {
$bundled_product = get_product($product_id);
} else {
$bundled_product = new WC_Product($product_id);
}
if ($bundled_product->is_on_sale()) {
$is_on_sale = true;
break;
}
}
return $is_on_sale;
} else {
if ($this->sale_price && $this->sale_price == $this->price) {
return true;
}
}
}
示例15: 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;
// Ticket stock is a simple reflection of remaining inventory for this item...
$stock = $product->get_stock_quantity();
// ...With some exceptions for global stock tickets
$stock = $this->set_stock_level_for_global_stock_tickets($stock, $event_id, $ticket_id);
$return->manage_stock($product->managing_stock());
$return->stock($stock);
$return->global_stock_mode(get_post_meta($ticket_id, '_global_stock_mode', true));
$return->global_stock_cap(get_post_meta($ticket_id, '_global_stock_cap', true));
$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);
}