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


PHP WC_Product::get_sku方法代码示例

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


在下文中一共展示了WC_Product::get_sku方法的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: get_name

 protected function get_name(WC_Product $product)
 {
     if ($product->get_sku()) {
         $identifier = $product->get_sku();
     } else {
         $identifier = '#' . (isset($product->variation_id) ? $product->variation_id : $product->id);
     }
     return sprintf('%s - %s', $identifier, $product->get_title());
 }
开发者ID:Automattic,项目名称:woocommerce-connect-client,代码行数:9,代码来源:class-wc-connect-shipping-label.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: get_articles

 /**
  * @param array $items
  *
  * @return array
  */
 public static function get_articles($items)
 {
     $articles = array();
     foreach ($items as $item => $values) {
         $product = new WC_Product($values['product_id']);
         $tax_rate = 100 * ($values['line_tax'] / $values['line_total']);
         $articles[] = array('id' => $values['product_id'], 'sku' => $product->get_sku(), 'name' => $values['name'], 'description' => $product->get_post_data()->post_content, 'url' => $product->get_permalink(), 'image_url' => wp_get_attachment_url(get_post_thumbnail_id($values['product_id'])), 'quantity' => (int) $values['qty'], 'price' => Aplazame_Filters::decimals($values['line_total']) / (int) $values['qty'], 'tax_rate' => Aplazame_Filters::decimals($tax_rate));
     }
     return $articles;
 }
开发者ID:aplazame,项目名称:woocommerce,代码行数:15,代码来源:Serializers.php

示例5: build_line_items

/**
 * Build the line items hash
 * @param array $items
 */
function build_line_items($items)
{
    $line_items = array();
    foreach ($items as $item) {
        $productmeta = new WC_Product($item['product_id']);
        $sku = $productmeta->get_sku();
        $line_items = array_merge($line_items, array(array('name' => $item['name'], 'unit_price' => floatval($item['line_total']) * 100, 'description' => $item['name'], 'quantity' => $item['qty'], 'sku' => $sku, 'type' => $item['type'])));
    }
    return $line_items;
}
开发者ID:pcuervo,项目名称:wp-yolcan,代码行数:14,代码来源:conekta_gateway_helper.php

示例6: API

 function export_products()
 {
     $api_key = get_option('pixelshop_key');
     $path = apply_filters('pixelshop/get_info', 'path');
     include_once $path . 'core/api.php';
     if (isset($_POST['nonce']) && wp_verify_nonce($_POST['nonce'], 'export_products') && $api_key !== false) {
         $api = new API($api_key);
         $args = array('post_type' => 'product', 'orderby' => $orderby, 'post_status' => 'publish', 'posts_per_page' => -1);
         $the_query = new WP_Query($args);
         $products = [];
         $i = 0;
         while ($the_query->have_posts()) {
             $i++;
             $the_query->the_post();
             $product = new WC_Product($the_query->post->ID);
             $thumb = wp_get_attachment_image_src(get_post_thumbnail_id($the_query->post->ID), array(250, 250));
             $products[$i] = ["sync_id" => $the_query->post->ID, "link" => get_permalink($the_query->post->ID), "title" => get_the_title(), "description" => get_the_excerpt(), "price" => $product->get_price(), "sku" => $product->get_sku(), "thumb" => $thumb[0], "tags" => ''];
             if (!isset($product->get_tags()->errors)) {
                 $tags = wp_get_object_terms($the_query->post->ID, 'product_tag');
                 $tags_list = '';
                 foreach ($tags as $tag) {
                     $tags_list .= $tag->name . ', ';
                 }
                 $products[$i]["tags"] = substr($tags_list, 0, -2);
             }
         }
         $export = $api->export->products($products);
         if (isset($export['error'])) {
             add_action('admin_notices', array($this, 'api_key_invalid'));
         } else {
             add_option('pixelshop_message', $export, '', 'yes');
             $time = 60 * 60 * 24;
             if (get_option('pxs_last_export') === false) {
                 add_option('pxs_last_export', time() + $time, '', 'no');
             } else {
                 update_option('pxs_last_export', time() + $time);
             }
         }
     }
 }
开发者ID:CBox,项目名称:pixelshop-wp,代码行数:40,代码来源:export.php

示例7: get_legacy_single_column_line_item

 /**
  * Get the order data format for a single column for all line items, compatible with the legacy (pre 3.0) CSV Export format
  *
  * Note this code was adapted from the old code to maintain compatibility as close as possible, so it should
  * not be modified unless absolutely necessary
  *
  * @since 3.0
  * @param array $order_data an array of order data for the given order
  * @param WC_Order $order the WC_Order object
  * @return array modified order data
  */
 private function get_legacy_single_column_line_item($order_data, WC_Order $order)
 {
     $line_items = array();
     foreach ($order->get_items() as $_ => $item) {
         $product = $order->get_product_from_item($item);
         if (!is_object($product)) {
             $product = new WC_Product(0);
         }
         $line_item = $item['name'];
         if ($product->get_sku()) {
             $line_item .= ' (' . $product->get_sku() . ')';
         }
         $line_item .= ' x' . $item['qty'];
         $item_meta = new WC_Order_Item_Meta($item);
         $variation = $item_meta->display(true, true);
         if ($variation) {
             $line_item .= ' - ' . str_replace(array("\r", "\r\n", "\n"), '', $variation);
         }
         $line_items[] = str_replace(array('“', '”'), '', $line_item);
     }
     $order_data['order_items'] = implode('; ', $line_items);
     // convert country codes to full name
     if (isset(WC()->countries->countries[$order->billing_country])) {
         $order_data['billing_country'] = WC()->countries->countries[$order->billing_country];
     }
     if (isset(WC()->countries->countries[$order->shipping_country])) {
         $order_data['shipping_country'] = WC()->countries->countries[$order->shipping_country];
     }
     // set order ID to order number
     $order_data['order_id'] = ltrim($order->get_order_number(), _x('#', 'hash before the order number', 'woocommerce-customer-order-csv-export'));
     return $order_data;
 }
开发者ID:arobbins,项目名称:spellestate,代码行数:43,代码来源:class-wc-customer-order-csv-export-compatibility.php

示例8: isset

 $first = isset($ourOrder->billing_first_name) ? $ourOrder->billing_first_name : '1';
 $last = isset($ourOrder->billing_last_name) ? $ourOrder->billing_last_name : '1';
 $customerEmail = isset($ourOrder->billing_email) ? $ourOrder->billing_email : '1';
 $orderTotal = isset($ourOrder->order_total) ? $ourOrder->order_total : '1';
 $orderDate = isset($ourOrder->order_date) ? $ourOrder->order_date : '1';
 $items = $ourOrder->get_items();
 //$discounts      = isset($ourOrder->get_total_discount()) ? $ourOrder->get_total_discount() : '1';
 $authProfile = isset($ourOrder->wc_authorize_net_cim_customer_profile_id) ? $ourOrder->wc_authorize_net_cim_customer_profile_id : '1';
 /*
  * 	The below foreach will pull the items array apart and process each item, finding its SKU and adding them to a comma separated list.
  */
 foreach ($items as $item) {
     $id = '';
     $id = isset($item['item_meta']['_variation_id']) ? $item['item_meta']['_variation_id'][0] : $item['item_meta']['_product_id'][0];
     $item = new WC_Product($id);
     $skus[] = $item->get_sku();
 }
 var_dump($skus);
 $orderItems = implode($skus, ",");
 $params = array('order_Id' => $orderID->ID, 'user_id' => $customerUser, 'subscription_id' => $subscriptionID, 'name' => $first . " " . $last, 'date' => date('Y-m-d', strtotime($orderDate)), 'email' => $customerEmail, 'products' => $orderItems, 'order_total' => $orderTotal, 'auth_profile' => $authProfile, 'address' => $ourOrder->get_formatted_shipping_address());
 $wpdb->insert($wpdb->prefix . 'orders_archived', $params);
 /*
  * 	This is the scary part of the plugin. While active, the below few lines will delete the original orders from the many 
  *  tables found in both wordpress and woocommerce after saving the important information to the archived orders table.
  */
 //if ($_GET['delete']) {
 if ($_POST['delete']) {
     wp_delete_post($orderID->ID);
     $wpdb->delete($wpdb->prefix . 'woocommerce_order_items', array("order_item_id" => $orderID->ID));
     $wpdb->delete($wpdb->prefix . 'woocommerce_order_itemmeta', array("order_item_id" => $orderID->ID));
 }
开发者ID:CamanoIslandCoffeeRoasters,项目名称:woocommerce-order-archiver,代码行数:31,代码来源:dashboard.php

示例9: array


//.........这里部分代码省略.........
             if ($key == $sort_by) {
                 echo '<div>' . __("Sort Criterion", "ts_visual_composer_extend") . ': ' . $value . '</div>';
             }
         }
         $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';
开发者ID:ryansm,项目名称:saud,代码行数:67,代码来源:ts_vcsc_woocommerce_custom_grid.php

示例10: wa_wps_display_slider


//.........这里部分代码省略.........

			line-height: <?php 
        echo $size_of_direction_arrows + 7;
        ?>
px;

			width: <?php 
        echo $size_of_direction_arrows + 10;
        ?>
px;

			height: <?php 
        echo $size_of_direction_arrows + 10;
        ?>
px;

			margin-top: -<?php 
        echo $size_of_direction_arrows;
        ?>
px;

		}

		.wps_image_carousel.wps_prev:hover, .wps_image_carousel .wps_next:hover {

			color: <?php 
        echo $arrows_hover_colour;
        ?>
;

		}

		#wa_wps_pager a {

			background: <?php 
        echo $arrows_hover_colour;
        ?>
;

		}

	</style>

	<?php 
        $slider_gallery = '';
        $slider_gallery .= '<div class="wps_image_carousel">';
        $slider_gallery .= '<div id="wa_chpc_slider" style="height:' . $item_height . 'px; overflow: hidden;">';
        if ($posts_order == "rand") {
            $posts_orderby = "rand";
        }
        $args_custom = array('posts_per_page' => $number_of_posts_to_display, 'post_type' => 'product', 'order' => $posts_order, 'orderby' => $posts_orderby, 'post_status' => 'publish', 'tax_query' => array(array('taxonomy' => 'product_cat', 'field' => 'slug', 'terms' => $category)));
        $myposts = get_posts($args_custom);
        foreach ($myposts as $post) {
            $post_title = $post->post_title;
            $post_link = get_permalink($post->ID);
            $post_content = strip_shortcodes($post->post_content);
            $text_type = $this->get_text_type($post, $excerpt_type);
            //woocommerce get data
            if (function_exists('get_product')) {
                $_product = get_product($post->ID);
            } else {
                $_product = new WC_Product($post->ID);
            }
            $slider_gallery .= '<div class="wps_foo_content" style="width:' . $item_width . 'px; height:' . $item_height . 'px;">';
            if ($display_image) {
                $slider_gallery .= '<span class="wps_img"><a href="' . $post_link . '">' . $this->get_post_image($post->ID, $image_size) . '</a></span>';
            }
            //Post title, Post Description, Post read more
            if ($display_title) {
                $slider_gallery .= '<br/><span class="wps_title"><a  style=" text-decoration:none;" href="' . $post_link . '">' . $post_title . '</a></span><br/>';
            }
            if ($display_excerpt) {
                $slider_gallery .= '<p><span class="wps_foo_con">' . $this->wa_wps_clean($text_type, $word_limit) . '</span></p>';
            }
            if ($display_read_more) {
                $slider_gallery .= '<br/><span class="wps_more"><a href="' . $post_link . '">' . $read_more_text . '</a></span>';
            }
            //display price
            if ($display_price) {
                $slider_gallery .= '<div class="wa_wps_price">' . $_product->get_price_html() . '</div>';
            }
            //display add to cart
            if ($display_add_to_cart) {
                $slider_gallery .= '<div class="wa_wps_add_to_cart"><a  rel="nofollow" data-product_id="' . $post->ID . '" data-product_sku="' . $_product->get_sku() . '" class="wa_wps_button add_to_cart_button product_type_simple" href="' . do_shortcode('[add_to_cart_url id="' . $post->ID . '"]') . '">Add to cart</a></div>';
            }
            $slider_gallery .= '</div>';
        }
        $slider_gallery .= '</div>';
        $slider_gallery .= '<div class="wps_clearfix"></div>';
        if ($display_controls) {
            $slider_gallery .= '<a class="wps_prev" id="wa_chpc_slider_prev" href="#"><span>‹</span></a>';
            $slider_gallery .= '<a class="wps_next" id="wa_chpc_slider_next" href="#"><span>›</span></a>';
        }
        if ($display_pagination) {
            $slider_gallery .= '<div class="wps_pagination" id="wa_wps_pager"></div>';
        }
        $slider_gallery .= '</div>';
        wp_reset_postdata();
        return $slider_gallery;
    }
开发者ID:nghieptovan,项目名称:newproject,代码行数:101,代码来源:wps.php

示例11: extract


//.........这里部分代码省略.........
     $loop = new WP_Query($args);
     if ($data_grid_machine == 'internal') {
         $class_name = 'ts-image-link-grid-frame';
     } else {
         if ($data_grid_machine == 'freewall') {
             wp_enqueue_script('ts-extend-freewall');
             $class_name = 'ts-image-freewall-grid-frame';
         }
     }
     if (function_exists('vc_shortcode_custom_css_class')) {
         $css_class = apply_filters(VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, $el_class . ' ' . $class_name . ' ' . vc_shortcode_custom_css_class($css, ' '), 'TS_VCSC_WooCommerce_ImageGrid_Basic', $atts);
     } else {
         $css_class = $class_name . ' ' . $el_class;
     }
     $fullwidth_allow = "true";
     $postCounter = 0;
     $modal_gallery = '';
     // Front-Edit Message
     if ($frontend_edit == "true") {
         $modal_gallery .= $grid_message;
         if ($loop->have_posts()) {
             while ($loop->have_posts()) {
                 $loop->the_post();
                 $matched_terms = 0;
                 $post_thumbnail = get_the_post_thumbnail();
                 if ($matched_terms == 0 && ($post_thumbnail != '' || $data_grid_invalid == "false")) {
                     $postCounter++;
                     if ($postCounter < $posts_limit + 1) {
                         $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();
                         $product_sku = $product->get_sku();
                         $attributes = $product->get_attributes();
                         $stock = $product->is_in_stock() ? 'true' : 'false';
                         if ('' != $post_thumbnail) {
                             $grid_image = wp_get_attachment_image_src(get_post_thumbnail_id(), $content_images_size);
                             $modal_image = wp_get_attachment_image_src(get_post_thumbnail_id(), 'full');
                             $grid_image = $grid_image[0];
                             $modal_image = $modal_image[0];
                         } else {
                             $grid_image = TS_VCSC_GetResourceURL('images/defaults/no_featured.png');
                             $modal_image = TS_VCSC_GetResourceURL('images/defaults/no_featured.png');
                         }
                         $categories = array();
                         if (taxonomy_exists($menu_tax)) {
                             foreach (get_the_terms($loop->post->ID, $menu_tax) as $term) {
                                 array_push($categories, $term->name);
                             }
                             $categories = implode($categories, ',');
                         }
                         $valid_images++;
                         $modal_gallery .= '<a style="' . $image_style . '" href="' . get_permalink() . '" target="_blank" title="' . get_the_title() . '">';
                         $modal_gallery .= '<img id="ts-image-link-picture-' . $randomizer . '-' . $i . '" class="ts-image-link-picture" src="' . $grid_image . '" rel="link-group-' . $randomizer . '" data-include="true" data-image="' . $modal_image . '" width="100%" height="auto" title="' . get_the_title() . '" data-groups="' . $categories . '" data-target="' . $data_grid_target . '" data-link="' . get_permalink() . '">';
                         $modal_gallery .= '</a>';
                         $categories = array();
                     }
                 }
             }
         } else {
             echo __("No products could be found.", "ts_visual_composer_extend");
         }
         wp_reset_postdata();
         wp_reset_query();
     } else {
开发者ID:Telemedellin,项目名称:fonvalmed,代码行数:67,代码来源:ts_vcsc_woocommerce_custom_image.php

示例12: extract_fields

 /**
  * Extracts the relevent product fields and adds them to the array
  * this is where the hard work of getting the data out occurs
  * Additionally do any formatting here....
  */
 private function extract_fields($p)
 {
     $data = array();
     // Go thru each field
     foreach ($this->fieldsToExport as $name => $field) {
         switch ($name) {
             case 'id':
                 array_push($data, $p->id);
                 break;
             case 'sku':
                 array_push($data, $p->get_sku());
                 break;
             case 'parent_id':
                 $parent = $p->get_parent();
                 if ($parent == 0) {
                     $parent = '';
                 }
                 array_push($data, $parent);
                 break;
             case 'parent_sku':
                 $parent = $p->get_parent();
                 //if we have a parent, get the sku
                 if (!empty($parent)) {
                     $temp = new WC_Product($parent);
                     array_push($data, $temp->get_sku());
                 } else {
                     //no parent so blank
                     array_push($data, '');
                 }
                 break;
             case 'name':
                 array_push($data, $p->get_title());
                 break;
             case 'product_type':
                 //Woo's product type is always null - bug somewhere
                 //array_push ( $data, $p->product_type );
                 $temp = wc_get_product($p->id);
                 array_push($data, $temp->product_type);
                 break;
             case 'shipping_class':
                 array_push($data, $p->get_shipping_class());
                 break;
             case 'width':
                 array_push($data, $p->width);
                 break;
             case 'length':
                 array_push($data, $p->length);
                 break;
             case 'height':
                 array_push($data, $p->height);
                 break;
             case 'managing_stock':
                 array_push($data, $p->managing_stock() ? "YES" : "NO");
                 break;
             case 'in_stock':
                 array_push($data, $p->is_in_stock() ? "YES" : "NO");
                 break;
             case 'qty_in_stock':
                 if ($p->managing_stock()) {
                     array_push($data, $p->stock);
                 } else {
                     array_push($data, '');
                 }
                 break;
             case 'downloadable':
                 array_push($data, $p->is_downloadable() ? 'YES' : 'NO');
                 break;
             case 'tax_status':
                 array_push($data, $p->get_tax_status());
                 break;
             case 'tax_class':
                 array_push($data, $p->get_tax_class());
                 break;
             case 'featured':
                 array_push($data, $p->is_featured() ? 'YES' : 'NO');
                 break;
             case 'price':
                 $price = $p->get_regular_price();
                 //no price check if there is one in the basic function - woo is funky
                 if ($price == '') {
                     $price = $p->get_price();
                 }
                 array_push($data, $price);
                 break;
             case 'sale_price':
                 array_push($data, $p->get_sale_price());
                 break;
             case 'sale_from':
                 $from = ($date = get_post_meta($p->id, '_sale_price_dates_from', true)) ? date_i18n($this->settings['date_format'], $date) : '';
                 array_push($data, $from);
                 break;
             case 'sale_to':
                 $to = ($date = get_post_meta($p->id, '_sale_price_dates_to', true)) ? date_i18n($this->settings['date_format'], $date) : '';
                 array_push($data, $to);
                 break;
//.........这里部分代码省略.........
开发者ID:robertjmcinnis,项目名称:fegym,代码行数:101,代码来源:Product.php

示例13: woocommerce_custom_product_columns

function woocommerce_custom_product_columns($column)
{
    global $post, $woocommerce;
    $product = new WC_Product($post->ID);
    switch ($column) {
        case "thumb":
            $product->get_image();
            break;
        case "name":
            $edit_link = get_edit_post_link($post->ID);
            $title = _draft_or_post_title();
            $post_type_object = get_post_type_object($post->post_type);
            $can_edit_post = current_user_can($post_type_object->cap->edit_post, $post->ID);
            echo '<strong><a class="row-title" href="' . $edit_link . '">' . $title . '</a>';
            _post_states($post);
            echo '</strong>';
            if ($post->post_parent > 0) {
                echo '&nbsp;&nbsp;&larr; <a href="' . get_edit_post_link($post->post_parent) . '">' . get_the_title($post->post_parent) . '</a>';
            }
            // Excerpt view
            if (isset($_GET['mode']) && $_GET['mode'] == 'excerpt') {
                echo apply_filters('the_excerpt', $post->post_excerpt);
            }
            // Get actions
            $actions = array();
            $actions['id'] = 'ID: ' . $post->ID;
            if ($can_edit_post && 'trash' != $post->post_status) {
                $actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . esc_attr(__('Edit this item inline', 'woocommerce')) . '">' . __('Quick&nbsp;Edit', 'woocommerce') . '</a>';
            }
            if (current_user_can($post_type_object->cap->delete_post, $post->ID)) {
                if ('trash' == $post->post_status) {
                    $actions['untrash'] = "<a title='" . esc_attr(__('Restore this item from the Trash', 'woocommerce')) . "' href='" . wp_nonce_url(admin_url(sprintf($post_type_object->_edit_link . '&amp;action=untrash', $post->ID)), 'untrash-' . $post->post_type . '_' . $post->ID) . "'>" . __('Restore', 'woocommerce') . "</a>";
                } elseif (EMPTY_TRASH_DAYS) {
                    $actions['trash'] = "<a class='submitdelete' title='" . esc_attr(__('Move this item to the Trash', 'woocommerce')) . "' href='" . get_delete_post_link($post->ID) . "'>" . __('Trash', 'woocommerce') . "</a>";
                }
                if ('trash' == $post->post_status || !EMPTY_TRASH_DAYS) {
                    $actions['delete'] = "<a class='submitdelete' title='" . esc_attr(__('Delete this item permanently', 'woocommerce')) . "' href='" . get_delete_post_link($post->ID, '', true) . "'>" . __('Delete Permanently', 'woocommerce') . "</a>";
                }
            }
            if ($post_type_object->public) {
                if (in_array($post->post_status, array('pending', 'draft'))) {
                    if ($can_edit_post) {
                        $actions['view'] = '<a href="' . esc_url(add_query_arg('preview', 'true', get_permalink($post->ID))) . '" title="' . esc_attr(sprintf(__('Preview &#8220;%s&#8221;', 'woocommerce'), $title)) . '" rel="permalink">' . __('Preview', 'woocommerce') . '</a>';
                    }
                } elseif ('trash' != $post->post_status) {
                    $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('View &#8220;%s&#8221;', 'woocommerce'), $title)) . '" rel="permalink">' . __('View', 'woocommerce') . '</a>';
                }
            }
            $actions = apply_filters('post_row_actions', $actions, $post);
            echo '<div class="row-actions">';
            $i = 0;
            $action_count = sizeof($actions);
            foreach ($actions as $action => $link) {
                ++$i;
                $i == $action_count ? $sep = '' : ($sep = ' | ');
                echo "<span class='{$action}'>{$link}{$sep}</span>";
            }
            echo '</div>';
            get_inline_data($post);
            /* Custom inline data for woocommerce */
            echo '
				<div class="hidden" id="woocommerce_inline_' . $post->ID . '">
					<div class="sku">' . $product->sku . '</div>
					<div class="regular_price">' . $product->regular_price . '</div>
					<div class="sale_price">' . $product->sale_price . '</div>
					<div class="weight">' . $product->weight . '</div>
					<div class="length">' . $product->length . '</div>
					<div class="width">' . $product->width . '</div>
					<div class="height">' . $product->height . '</div>
					<div class="visibility">' . $product->visibility . '</div>
					<div class="stock_status">' . $product->stock_status . '</div>
					<div class="stock">' . $product->stock . '</div>
					<div class="manage_stock">' . $product->manage_stock . '</div>
					<div class="featured">' . $product->featured . '</div>
					<div class="product_type">' . $product->product_type . '</div>
					<div class="product_is_virtual">' . $product->virtual . '</div>
				</div>
			';
            break;
        case "sku":
            if ($product->get_sku()) {
                echo $product->get_sku();
            } else {
                echo '<span class="na">&ndash;</span>';
            }
            break;
        case "product_type":
            if ($product->product_type == 'grouped') {
                echo '<span class="product-type tips ' . $product->product_type . '" tip="' . __('Grouped', 'woocommerce') . '"></span>';
            } elseif ($product->product_type == 'external') {
                echo '<span class="product-type tips ' . $product->product_type . '" tip="' . __('External/Affiliate', 'woocommerce') . '"></span>';
            } elseif ($product->product_type == 'simple') {
                if ($product->is_virtual()) {
                    echo '<span class="product-type tips virtual" tip="' . __('Virtual', 'woocommerce') . '"></span>';
                } elseif ($product->is_downloadable()) {
                    echo '<span class="product-type tips downloadable" tip="' . __('Downloadable', 'woocommerce') . '"></span>';
                } else {
                    echo '<span class="product-type tips ' . $product->product_type . '" tip="' . __('Simple', 'woocommerce') . '"></span>';
                }
            } elseif ($product->product_type == 'variable') {
//.........这里部分代码省略.........
开发者ID:rosslavery,项目名称:woocommerce,代码行数:101,代码来源:product.php

示例14: get_orders_csv_row

 /**
  * Get the order data for a single CSV row
  *
  * Note items are keyed according to the column header keys above so these can be modified using
  * the provider filter without needing to worry about the array order
  *
  * @since 3.0
  * @param int $order_id the WC_Order ID
  * @return array order data in the format key => content
  */
 private function get_orders_csv_row($order_id)
 {
     $order = wc_get_order($order_id);
     $line_items = $shipping_items = $fee_items = $tax_items = $coupon_items = array();
     // get line items
     foreach ($order->get_items() as $item_id => $item) {
         $product = $order->get_product_from_item($item);
         if (!is_object($product)) {
             $product = new WC_Product(0);
         }
         $item_meta = new WC_Order_Item_Meta(SV_WC_Plugin_Compatibility::is_wc_version_gte_2_4() ? $item : $item['item_meta']);
         $meta = $item_meta->display(true, true);
         if ($meta) {
             // remove newlines
             $meta = str_replace(array("\r", "\r\n", "\n"), '', $meta);
             // switch reserved chars (:;|) to =
             $meta = str_replace(array(': ', ':', ';', '|'), '=', $meta);
         }
         $line_item = array('name' => html_entity_decode($product->get_title() ? $product->get_title() : $item['name'], ENT_NOQUOTES, 'UTF-8'), 'sku' => $product->get_sku(), 'quantity' => $item['qty'], 'total' => wc_format_decimal($order->get_line_total($item), 2), 'refunded' => wc_format_decimal($order->get_total_refunded_for_item($item_id), 2), 'meta' => html_entity_decode($meta, ENT_NOQUOTES, 'UTF-8'));
         // add line item tax
         $line_tax_data = isset($item['line_tax_data']) ? $item['line_tax_data'] : array();
         $tax_data = maybe_unserialize($line_tax_data);
         $line_item['tax'] = isset($tax_data['total']) ? wc_format_decimal(wc_round_tax_total(array_sum((array) $tax_data['total'])), 2) : '';
         /**
          * CSV Order Export Line Item.
          *
          * Filter the individual line item entry for the default export
          *
          * @since 3.0.6
          * @param array $line_item {
          *     line item data in key => value format
          *     the keys are for convenience and not used for exporting. Make
          *     sure to prefix the values with the desired line item entry name
          * }
          *
          * @param array $item WC order item data
          * @param WC_Product $product the product
          * @param WC_Order $order the order
          * @param \WC_Customer_Order_CSV_Export_Generator $this, generator instance
          */
         $line_item = apply_filters('wc_customer_order_csv_export_order_line_item', $line_item, $item, $product, $order, $this);
         if ('default_one_row_per_item' !== $this->order_format && is_array($line_item)) {
             foreach ($line_item as $name => $value) {
                 $line_item[$name] = $name . ':' . $value;
             }
             $line_item = implode('|', $line_item);
         }
         if ($line_item) {
             $line_items[] = $line_item;
         }
     }
     foreach ($order->get_shipping_methods() as $_ => $shipping_item) {
         $shipping_items[] = implode('|', array('method:' . $shipping_item['name'], 'total:' . wc_format_decimal($shipping_item['cost'], 2)));
     }
     // get fee items & total
     $fee_total = 0;
     $fee_tax_total = 0;
     foreach ($order->get_fees() as $fee_id => $fee) {
         $fee_items[] = implode('|', array('name:' . $fee['name'], 'total:' . wc_format_decimal($fee['line_total'], 2), 'tax:' . wc_format_decimal($fee['line_tax'], 2)));
         $fee_total += $fee['line_total'];
         $fee_tax_total += $fee['line_tax'];
     }
     // get tax items
     foreach ($order->get_tax_totals() as $tax_code => $tax) {
         $tax_items[] = implode('|', array('code:' . $tax_code, 'total:' . wc_format_decimal($tax->amount, 2)));
     }
     // add coupons
     foreach ($order->get_items('coupon') as $_ => $coupon_item) {
         $coupon = new WC_Coupon($coupon_item['name']);
         $coupon_post = get_post($coupon->id);
         $coupon_items[] = implode('|', array('code:' . $coupon_item['name'], 'description:' . (is_object($coupon_post) ? $coupon_post->post_excerpt : ''), 'amount:' . wc_format_decimal($coupon_item['discount_amount'], 2)));
     }
     $order_data = array('order_id' => $order->id, 'order_number' => $order->get_order_number(), 'order_date' => $order->order_date, 'status' => $order->get_status(), 'shipping_total' => $order->get_total_shipping(), 'shipping_tax_total' => wc_format_decimal($order->get_shipping_tax(), 2), 'fee_total' => wc_format_decimal($fee_total, 2), 'fee_tax_total' => wc_format_decimal($fee_tax_total, 2), 'tax_total' => wc_format_decimal($order->get_total_tax(), 2), 'cart_discount' => SV_WC_Plugin_Compatibility::is_wc_version_gte_2_3() ? wc_format_decimal($order->get_total_discount(), 2) : wc_format_decimal($order->get_cart_discount(), 2), 'order_discount' => SV_WC_Plugin_Compatibility::is_wc_version_gte_2_3() ? wc_format_decimal($order->get_total_discount(), 2) : wc_format_decimal($order->get_order_discount(), 2), 'discount_total' => wc_format_decimal($order->get_total_discount(), 2), 'order_total' => wc_format_decimal($order->get_total(), 2), 'refunded_total' => wc_format_decimal($order->get_total_refunded(), 2), 'order_currency' => $order->get_order_currency(), 'payment_method' => $order->payment_method, 'shipping_method' => $order->get_shipping_method(), 'customer_id' => $order->get_user_id(), 'billing_first_name' => $order->billing_first_name, 'billing_last_name' => $order->billing_last_name, 'billing_company' => $order->billing_company, 'billing_email' => $order->billing_email, 'billing_phone' => $order->billing_phone, 'billing_address_1' => $order->billing_address_1, 'billing_address_2' => $order->billing_address_2, 'billing_postcode' => $order->billing_postcode, 'billing_city' => $order->billing_city, 'billing_state' => $order->billing_state, 'billing_country' => $order->billing_country, 'shipping_first_name' => $order->shipping_first_name, 'shipping_last_name' => $order->shipping_last_name, 'shipping_company' => $order->shipping_company, 'shipping_address_1' => $order->shipping_address_1, 'shipping_address_2' => $order->shipping_address_2, 'shipping_postcode' => $order->shipping_postcode, 'shipping_city' => $order->shipping_city, 'shipping_state' => $order->shipping_state, 'shipping_country' => $order->shipping_country, 'customer_note' => $order->customer_note, 'shipping_items' => implode(';', $shipping_items), 'fee_items' => implode(';', $fee_items), 'tax_items' => implode(';', $tax_items), 'coupon_items' => implode(';', $coupon_items), 'order_notes' => implode('|', $this->get_order_notes($order)), 'download_permissions' => $order->download_permissions_granted ? $order->download_permissions_granted : 0);
     if ('default_one_row_per_item' === $this->order_format) {
         $new_order_data = array();
         foreach ($line_items as $item) {
             $order_data['item_name'] = $item['name'];
             $order_data['item_sku'] = $item['sku'];
             $order_data['item_quantity'] = $item['quantity'];
             $order_data['item_tax'] = $item['tax'];
             $order_data['item_total'] = $item['total'];
             $order_data['item_refunded'] = $item['refunded'];
             $order_data['item_meta'] = $item['meta'];
             /**
              * CSV Order Export Row for One Row per Item.
              *
              * Filter the individual row data for the order export
              *
              * @since 3.3.0
              * @param array $order_data {
//.........这里部分代码省略.........
开发者ID:daanbakker1995,项目名称:vanteun,代码行数:101,代码来源:class-wc-customer-order-csv-export-generator.php

示例15: custom_add_tax

function custom_add_tax($instance)
{
    if (is_admin() && !defined('DOING_AJAX')) {
        return;
    }
    global $woocommerce;
    $fee = 0;
    foreach ($woocommerce->cart->get_cart() as $cart_item_key => $values) {
        $product = new WC_Product($values['product_id']);
        $sku = $product->get_sku();
        $qty = $values['quantity'];
        include_once TEMPLATEPATH . "/portal/api/Api.php";
        include_once TEMPLATEPATH . "/portal/api/Setting.php";
        include_once TEMPLATEPATH . "/portal/api/RequestParams.php";
        include_once TEMPLATEPATH . "/portal/api/BQ_Base.php";
        include_once TEMPLATEPATH . "/portal/api/BQ_CustomerManualInvoiceQuoteRequest.php";
        $Api = new Api();
        $requestParams = new requestParams();
        $BQ = new BQ_CustomerManualInvoiceQuoteRequest();
        // $BQ->set_billingProfileId('3');
        $BQ->set_customerId(WC()->session->get('customerId'));
        $skus = array($sku);
        $BQ->set_Skus($skus);
        $requestParams->id = Setting::CLEC_ID;
        $requestParams->firstName = Setting::CLEC_FIRSTNAME;
        $requestParams->lastName = Setting::CLEC_LASTNAME;
        $requestParams->details = $BQ;
        $request = $Api->buildRequest($requestParams);
        $Api->callAPI(Setting::URL, $request);
        $BQ->set_response($Api->response);
        // echo '<pre>' . var_export( $BQ->get_response(), true ) . '</pre>';
        // echo '<pre>' . var_export( $BQ->get_tax_total(), true ) . '</pre>';
        $fee += $BQ->get_tax_total();
    }
    // echo '<pre>' . var_export( $woocommerce->cart->get_cart(), true ) . '</pre>';
    // echo '<pre>' . var_export( $instance, true ) . '</pre>';
    $woocommerce->cart->add_fee('Sales Tax', $fee, true, 'standard');
    return $instance;
}
开发者ID:jamessun,项目名称:assist-portal,代码行数:39,代码来源:functions.php


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