本文整理汇总了PHP中WC_Product::get_title方法的典型用法代码示例。如果您正苦于以下问题:PHP WC_Product::get_title方法的具体用法?PHP WC_Product::get_title怎么用?PHP WC_Product::get_title使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WC_Product
的用法示例。
在下文中一共展示了WC_Product::get_title方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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());
}
示例2: ajax_get_products_per_period
public function ajax_get_products_per_period()
{
$product_num = isset($_POST['product_num']) ? $_POST['product_num'] : 10;
$start_date = isset($_POST['start_date']) ? $_POST['start_date'] : null;
$end_date = isset($_POST['end_date']) ? $_POST['end_date'] : null;
$results = [];
$stats = $this->get_products_per_period(100, $start_date, $end_date);
//wcds_var_dump($stats);
/*Format:
array(4) {
[0]=>
array(4) {
["total_earning"]=>
string(1) "4"
["total_purchases"]=>
string(1) "4"
["prod_id"]=>
string(2) "12"
["prod_variation_id"]=>
string(1) "0"
}
*/
$counter = 0;
$wpml_helper = new WCDS_Wpml();
foreach ($stats as $prod_id => $product) {
//WPML: Merge product stats by id
$stats[$prod_id]['total_earning'] = round($product['total_earning'], 2);
$stats[$prod_id]['permalink'] = get_permalink($prod_id);
if ($wpml_helper->wpml_is_active()) {
$original_id = $wpml_helper->get_original_id($prod_id);
$product_temp = new WC_Product($original_id);
$stats[$prod_id]['prod_title'] = $product_temp->get_title();
$stats[$prod_id]['permalink'] = get_permalink($original_id);
//wcds_var_dump($prod_id." -> ".$original_id);
if (!isset($results[$original_id])) {
//wcds_var_dump("new");
$results[$original_id] = $stats[$prod_id];
} else {
//wcds_var_dump("update");
$results[$original_id]["total_earning"] += $product["total_purchases"];
$results[$original_id]["total_earning"] += $product["total_earning"];
$results[$original_id]["total_earning"] = round($results[$original_id]['total_earning'], 2);
}
} else {
$results[$prod_id] = $stats[$prod_id];
}
if (++$counter == $product_num) {
break;
}
}
usort($results, function ($a, $b) {
return $b['total_earning'] - $a['total_earning'];
});
echo json_encode($results);
wp_die();
}
示例3: format_wc_product_update_for_square_api
/**
* Convert a WC Product into a Square Item for Update
*
* Updates (PUT) don't accept the same parameters (namely variations) as Creation
* See: https://docs.connect.squareup.com/api/connect/v1/index.html#put-itemid
*
* @param WC_Product $wc_product
* @param bool $include_category
* @return array
*/
public static function format_wc_product_update_for_square_api(WC_Product $wc_product, $include_category = false)
{
$formatted = array('name' => $wc_product->get_title(), 'description' => $wc_product->post->post_content, 'visibility' => 'PUBLIC');
if ($include_category) {
if ($square_cat_id = self::get_square_category_id_for_wc_product($wc_product)) {
$formatted['category_id'] = $square_cat_id;
}
}
return array_filter($formatted);
}
示例4: widget
/**
* widget function.
*
* @see WP_Widget
* @access public
* @param array $args
* @param array $instance
* @return void
*/
function widget($args, $instance)
{
global $comments, $comment, $woocommerce;
$cache = wp_cache_get('widget_recent_reviews', 'widget');
if (!is_array($cache)) {
$cache = array();
}
if (isset($cache[$args['widget_id']])) {
echo $cache[$args['widget_id']];
return;
}
ob_start();
extract($args);
$title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Reviews', 'woocommerce') : $instance['title'], $instance, $this->id_base);
if (!($number = absint($instance['number']))) {
$number = 5;
}
$comments = get_comments(array('number' => $number, 'status' => 'approve', 'post_status' => 'publish', 'post_type' => 'product'));
if ($comments) {
echo $before_widget;
if ($title) {
echo $before_title . $title . $after_title;
}
echo '<ul class="product_list_widget">';
foreach ((array) $comments as $comment) {
$_product = new WC_Product($comment->comment_post_ID);
$star_size = apply_filters('woocommerce_star_rating_size_recent_reviews', 16);
$rating = get_comment_meta($comment->comment_ID, 'rating', true);
$rating_html = '<div class="star-rating" title="' . $rating . '">
<span style="width:' . $rating * $star_size . 'px">' . $rating . ' ' . __('out of 5', 'woocommerce') . '</span>
</div>';
echo '<li><a href="' . esc_url(get_comment_link($comment->comment_ID)) . '">';
echo $_product->get_image();
echo $_product->get_title() . '</a>';
echo $rating_html;
printf(_x('by %1$s', 'by comment author', 'woocommerce'), get_comment_author()) . '</li>';
}
echo '</ul>';
echo $after_widget;
}
$content = ob_get_clean();
if (isset($args['widget_id'])) {
$cache[$args['widget_id']] = $content;
}
echo $content;
wp_cache_set('widget_recent_reviews', $cache, 'widget');
}
示例5: get_product_data
/**
* Get product data.
*
* @param WC_Product $product
* @return array
*/
protected function get_product_data($product)
{
$data = array('id' => (int) $product->is_type('variation') ? $product->get_variation_id() : $product->id, 'name' => $product->get_title(), 'slug' => $product->get_post_data()->post_name, 'permalink' => $product->get_permalink(), 'date_created' => wc_rest_prepare_date_response($product->get_post_data()->post_date_gmt), 'date_modified' => wc_rest_prepare_date_response($product->get_post_data()->post_modified_gmt), 'type' => $product->product_type, 'status' => $product->get_post_data()->post_status, 'featured' => $product->is_featured(), 'catalog_visibility' => $product->visibility, 'description' => wpautop(do_shortcode($product->get_post_data()->post_content)), 'short_description' => apply_filters('woocommerce_short_description', $product->get_post_data()->post_excerpt), '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->sale_price_dates_from ? date('Y-m-d', $product->sale_price_dates_from) : '', 'date_on_sale_to' => $product->sale_price_dates_to ? date('Y-m-d', $product->sale_price_dates_to) : '', 'price_html' => $product->get_price_html(), 'on_sale' => $product->is_on_sale(), 'purchasable' => $product->is_purchasable(), 'total_sales' => (int) get_post_meta($product->id, 'total_sales', true), 'virtual' => $product->is_virtual(), 'downloadable' => $product->is_downloadable(), 'downloads' => $this->get_downloads($product), 'download_limit' => '' !== $product->download_limit ? (int) $product->download_limit : -1, 'download_expiry' => '' !== $product->download_expiry ? (int) $product->download_expiry : -1, 'download_type' => $product->download_type ? $product->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->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' => (int) $product->get_shipping_class_id(), 'reviews_allowed' => 'open' === $product->get_post_data()->comment_status, 'average_rating' => wc_format_decimal($product->get_average_rating(), 2), 'rating_count' => (int) $product->get_rating_count(), 'related_ids' => array_map('absint', array_values($product->get_related())), 'upsell_ids' => array_map('absint', $product->get_upsells()), 'cross_sell_ids' => array_map('absint', $product->get_cross_sells()), 'parent_id' => $product->is_type('variation') ? $product->parent->id : $product->get_post_data()->post_parent, 'purchase_note' => wpautop(do_shortcode(wp_kses_post($product->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' => $this->get_product_menu_order($product));
return $data;
}
示例6: get_product_from_post
private function get_product_from_post($post_id)
{
$woocommerce_ver_below_2_1 = false;
if (version_compare(WOOCOMMERCE_VERSION, '2.1', '<')) {
$woocommerce_ver_below_2_1 = true;
}
if ($woocommerce_ver_below_2_1) {
$product = new WC_Product_Simple($post_id);
} else {
$product = new WC_Product($post_id);
}
//$post_categories = wp_get_post_categories( $post_id );
//$categories = get_the_category();
try {
$thumbnail = $product->get_image();
if ($thumbnail) {
if (preg_match('/data-lazy-src="([^\\"]+)"/s', $thumbnail, $match)) {
$thumbnail = $match[1];
} else {
if (preg_match('/data-lazy-original="([^\\"]+)"/s', $thumbnail, $match)) {
$thumbnail = $match[1];
} else {
if (preg_match('/lazy-src="([^\\"]+)"/s', $thumbnail, $match)) {
// Animate Lazy Load Wordpress Plugin
$thumbnail = $match[1];
} else {
if (preg_match('/data-echo="([^\\"]+)"/s', $thumbnail, $match)) {
$thumbnail = $match[1];
} else {
preg_match('/<img(.*)src(.*)=(.*)"(.*)"/U', $thumbnail, $result);
$thumbnail = array_pop($result);
}
}
}
}
}
} catch (Exception $e) {
$err_msg = "exception raised in thumbnails";
self::send_error_report($err_msg);
$thumbnail = '';
}
// handling scheduled sale price update
if (!$woocommerce_ver_below_2_1) {
$sale_price_dates_from = get_post_meta($post_id, '_sale_price_dates_from', true);
$sale_price_dates_to = get_post_meta($post_id, '_sale_price_dates_to', true);
if ($sale_price_dates_from || $sale_price_dates_to) {
self::schedule_sale_price_update($post_id, null);
}
if ($sale_price_dates_from) {
self::schedule_sale_price_update($post_id, $sale_price_dates_from);
}
if ($sale_price_dates_to) {
self::schedule_sale_price_update($post_id, $sale_price_dates_to);
}
}
$product_tags = array();
foreach (wp_get_post_terms($post_id, 'product_tag') as $tag) {
$product_tags[] = $tag->name;
}
$product_brands = array();
if (taxonomy_exists('product_brand')) {
foreach (wp_get_post_terms($post_id, 'product_brand') as $brand) {
$product_brands[] = $brand->name;
}
}
$taxonomies = array();
try {
$all_taxonomies = get_option('wcis_taxonomies');
if (is_array($all_taxonomies)) {
foreach ($all_taxonomies as $taxonomy) {
if (taxonomy_exists($taxonomy) && !array_key_exists($taxonomy, $taxonomies)) {
foreach (wp_get_post_terms($post_id, $taxonomy) as $taxonomy_value) {
if (!array_key_exists($taxonomy, $taxonomies)) {
$taxonomies[$taxonomy] = array();
}
$taxonomies[$taxonomy][] = $taxonomy_value->name;
}
}
}
}
} catch (Exception $e) {
}
$acf_fields = array();
try {
if (class_exists('acf') && function_exists('get_field')) {
$all_acf_fields = get_option('wcis_acf_fields');
if (is_array($all_acf_fields)) {
foreach ($all_acf_fields as $acf_field_name) {
$acf_field_value = get_field($acf_field_name, $post_id);
if ($acf_field_value) {
$acf_fields[$acf_field_name] = $acf_field_value;
}
}
}
}
} 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);
//.........这里部分代码省略.........
示例7: wc_cp_composited_product_title
/**
* Composited product title template.
*
* @param WC_Product $product
* @param string $component_id
* @param WC_Product_Composite $composite
* @return void
*/
function wc_cp_composited_product_title($product, $component_id, $composite)
{
$component_data = $composite->get_component_data($component_id);
$hide_product_title = isset($component_data['hide_product_title']) ? $component_data['hide_product_title'] : 'no';
$show_selection_ui = true;
if ($composite->is_component_static($component_id)) {
$show_selection_ui = false;
}
// Current selection title.
if ($hide_product_title !== 'yes') {
if ($show_selection_ui) {
wc_get_template('composited-product/selection.php', array('component_id' => $component_id, 'composite' => $composite), '', WC_CP()->plugin_path() . '/templates/');
}
wc_get_template('composited-product/title.php', array('title' => $product->get_title(), 'product_id' => $product->id, 'component_id' => $component_id, 'composite' => $composite, 'quantity' => ''), '', WC_CP()->plugin_path() . '/templates/');
}
// Clear current selection.
if ($show_selection_ui) {
?>
<p class="component_section_title clear_component_options_wrapper">
<a class="clear_component_options" href="#clear_component"><?php
echo __('Clear selection', 'woocommerce-composite-products');
?>
</a>
</p><?php
}
}
示例8: wc_add_to_cart_message
public function wc_add_to_cart_message($message, $product_id)
{
$integration = $this->load_integration();
if (empty($integration->get_option('facebookpixel'))) {
return;
}
$product = new WC_Product($product_id);
ob_start('tracker');
?>
<img height="1" width="1" style="display:none"
src="https://www.facebook.com/tr?<?php
echo http_build_query(array('id' => $integration->get_option('facebookpixel'), 'ev' => 'AddToCart', 'noscript' => 1, 'content_ids' => $product->get_sku(), 'content_name' => $product->get_title(), 'currency' => get_woocommerce_currency(), 'value' => $product->get_price(), 'content_type' => 'product'));
?>
"/>
<?php
$_tracker = ob_get_clean();
$message .= ' ' . $_tracker;
return $message;
}
示例9: disallow_bundled_item_subs
/**
* Bundles with subscriptions can't be composited.
*
* @param boolean $passed
* @param WC_Product $bundle
* @return boolean
*/
public static function disallow_bundled_item_subs($passed, $bundle)
{
if ($bundle->contains_sub()) {
wc_add_notice(sprintf(__('The configuration you have selected cannot be added to the cart. "%s" cannot be purchased.', 'woocommerce-product-bundles'), $bundle->get_title()), 'error');
return false;
}
return $passed;
}
示例10: 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);
}
示例11: array
/**
* Gets a user's downloadable products if they are logged in
*
* @return array downloads Array of downloadable products
*/
function get_downloadable_products()
{
global $wpdb;
$downloads = array();
if (is_user_logged_in()) {
$user_info = get_userdata(get_current_user_id());
$results = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "woocommerce_downloadable_product_permissions WHERE user_id = '%s';", get_current_user_id()));
if ($results) {
foreach ($results as $result) {
if ($result->order_id > 0) {
$order = new WC_Order($result->order_id);
if ($order->status != 'completed' && $order->status != 'processing') {
continue;
}
$product_post = get_post($result->product_id);
if ($product_post->post_type == 'product_variation') {
$_product = new WC_Product_Variation($result->product_id);
} else {
$_product = new WC_Product($result->product_id);
}
if ($_product->exists) {
$download_name = $_product->get_title();
} else {
$download_name = '#' . $result->product_id;
}
$downloads[] = array('download_url' => add_query_arg('download_file', $result->product_id, add_query_arg('order', $result->order_key, add_query_arg('email', $user_info->user_email, home_url()))), 'product_id' => $result->product_id, 'download_name' => $download_name, 'order_id' => $order->id, 'order_key' => $order->order_key, 'downloads_remaining' => $result->downloads_remaining);
}
}
}
}
return apply_filters('woocommerce_customer_get_downloadable_products', $downloads);
}
示例12: replace_expiration_vars
/**
* @param string $content
* @param License $license
*
* @return string
*/
private function replace_expiration_vars($content, $license)
{
// get user
$user = get_user_by('id', $license->get_user_id());
// get first name
$fname = 'there';
if (!empty($user) && !empty($user->first_name)) {
$fname = $user->first_name;
}
// get WooCommerce product object
$wc_product = new \WC_Product($license->get_product_id());
// get parent product if the product has one
if (0 != $wc_product->get_parent()) {
$wc_product = new \WC_Product($wc_product->get_parent());
}
$content = str_ireplace(':fname:', $fname, $content);
$content = str_ireplace(':product:', $wc_product->get_title(), $content);
$content = str_ireplace(':license-key:', $license->get_key(), $content);
$content = str_ireplace(':license-expiration-date:', $license->get_date_expires() ? $license->get_date_expires()->format('M d Y') : '', $content);
$content = str_ireplace(':renewal-link:', $license->get_renewal_url(), $content);
return $content;
}
示例13: isset
/**
* WCMp Product Report sorting
*/
function product_report_sort()
{
global $WCMp;
$sort_choosen = isset($_POST['sort_choosen']) ? $_POST['sort_choosen'] : '';
$report_array = isset($_POST['report_array']) ? $_POST['report_array'] : array();
$report_bk = isset($_POST['report_bk']) ? $_POST['report_bk'] : array();
$max_total_sales = isset($_POST['max_total_sales']) ? $_POST['max_total_sales'] : 0;
$total_sales_sort = isset($_POST['total_sales_sort']) ? $_POST['total_sales_sort'] : array();
$admin_earning_sort = isset($_POST['admin_earning_sort']) ? $_POST['admin_earning_sort'] : array();
$i = 0;
$max_value = 10;
$report_sort_arr = array();
if ($sort_choosen == 'total_sales_desc') {
arsort($total_sales_sort);
foreach ($total_sales_sort as $product_id => $value) {
if ($i++ < $max_value) {
$report_sort_arr[$product_id]['total_sales'] = $report_bk[$product_id]['total_sales'];
$report_sort_arr[$product_id]['admin_earning'] = $report_bk[$product_id]['admin_earning'];
}
}
} else {
if ($sort_choosen == 'total_sales_asc') {
asort($total_sales_sort);
foreach ($total_sales_sort as $product_id => $value) {
if ($i++ < $max_value) {
$report_sort_arr[$product_id]['total_sales'] = $report_bk[$product_id]['total_sales'];
$report_sort_arr[$product_id]['admin_earning'] = $report_bk[$product_id]['admin_earning'];
}
}
} else {
if ($sort_choosen == 'admin_earning_desc') {
arsort($admin_earning_sort);
foreach ($admin_earning_sort as $product_id => $value) {
if ($i++ < $max_value) {
$report_sort_arr[$product_id]['total_sales'] = $report_bk[$product_id]['total_sales'];
$report_sort_arr[$product_id]['admin_earning'] = $report_bk[$product_id]['admin_earning'];
}
}
} else {
if ($sort_choosen == 'admin_earning_asc') {
asort($admin_earning_sort);
foreach ($admin_earning_sort as $product_id => $value) {
if ($i++ < $max_value) {
$report_sort_arr[$product_id]['total_sales'] = $report_bk[$product_id]['total_sales'];
$report_sort_arr[$product_id]['admin_earning'] = $report_bk[$product_id]['admin_earning'];
}
}
}
}
}
}
$report_chart = $report_html = '';
if (sizeof($report_sort_arr) > 0) {
foreach ($report_sort_arr as $product_id => $sales_report) {
$width = $sales_report['total_sales'] > 0 ? round($sales_report['total_sales']) / round($max_total_sales) * 100 : 0;
$width2 = $sales_report['admin_earning'] > 0 ? round($sales_report['admin_earning']) / round($max_total_sales) * 100 : 0;
$product = new WC_Product($product_id);
$product_url = admin_url('post.php?post=' . $product_id . '&action=edit');
$report_chart .= '<tr><th><a href="' . $product_url . '">' . $product->get_title() . '</a></th>
<td width="1%"><span>' . woocommerce_price($sales_report['total_sales']) . '</span><span class="alt">' . woocommerce_price($sales_report['admin_earning']) . '</span></td>
<td class="bars">
<span style="width:' . esc_attr($width) . '%"> </span>
<span class="alt" style="width:' . esc_attr($width2) . '%"> </span>
</td></tr>';
}
$report_html = '
<h4>' . __("Sales and Earnings", $WCMp->text_domain) . '</h4>
<div class="bar_indecator">
<div class="bar1"> </div>
<span class="">' . __("Gross Sales", $WCMp->text_domain) . '</span>
<div class="bar2"> </div>
<span class="">' . __("My Earnings", $WCMp->text_domain) . '</span>
</div>
<table class="bar_chart">
<thead>
<tr>
<th>' . __("Month", $WCMp->text_domain) . '</th>
<th colspan="2">' . __("Sales Report", $WCMp->text_domain) . '</th>
</tr>
</thead>
<tbody>
' . $report_chart . '
</tbody>
</table>
';
} else {
$report_html = '<tr><td colspan="3">' . __('No product was sold in the given period.', $WCMp->text_domain) . '</td></tr>';
}
echo $report_html;
die;
}
示例14: woocommerce_cart_items_meta_box
//.........这里部分代码省略.........
} else {
echo '-';
}
?>
<input type="hidden" class="item_id" name="item_id[<?php
echo $loop;
?>
]" value="<?php
if (isset($item->id) && $item->id != '') {
echo esc_attr($item->id);
}
?>
" />
<input type="hidden" name="item_name[<?php
echo $loop;
?>
]" value="<?php
echo esc_attr($item->id);
?>
" />
<?php
if (isset($item->variation_id)) {
?>
<input type="hidden" name="item_variation[<?php
echo $loop;
?>
]" value="<?php
echo esc_attr($item->variation_id);
?>
" /> <?php
}
?>
</td>
<td class="name" width="20%">
<div class="row-actions">
<span class="view"><a href="<?php
echo esc_url(admin_url('post.php?post=' . $_product->id . '&action=edit'));
?>
"><?php
_e('View product', 'woocommerce');
?>
</a>
</div>
<?php
echo $_product->get_title();
?>
<?php
if (isset($_product->variation_data)) {
echo '<br/>' . woocommerce_get_formatted_variation($_product->variation_data, true);
}
?>
</td>
<?php
//do_action('woocommerce_admin_order_item_values', $_product, $item);
?>
<td class="price" width="20%"><p>
<?php
echo $_product->get_price_html();
?>
</p></td>
<td class="quantity" width="20%"><p>
<?php
echo $item['quantity'];
?>
</p></td>
</tr>
<?php
}
?>
<?php
$loop++;
}
} else {
//Explain to the user why no products could show up in a recently abandoned / opened cart
?>
<span style="color:gray;"'>No Products In The Cart</span> <?php
av8_tooltip(__('When a customer adds items to a cart, then abandones the cart for a considerable amount of time, the browser often deletes the cart data. The cart still belongs to the customer, but their brower removed the products. :( But hey! This indicates that they came back. And might be ready to purchase.', 'woocommerce_cart_reports'));
?>
<?php
}
?>
</tbody>
</table>
</div>
<script type="text/javascript">
</script>
<?php
}
示例15: do_payment
/**
* Set up the DoExpressCheckoutPayment request
*
* @link https://developer.paypal.com/docs/classic/express-checkout/integration-guide/ECGettingStarted/#id084RN060BPF
* @link https://developer.paypal.com/webapps/developer/docs/classic/api/merchant/DoExpressCheckoutPayment_API_Operation_NVP/
*
* @since 3.0.0
* @param \WC_Order $order order object
* @param string $type
*/
private function do_payment(WC_Order $order, $type)
{
$this->set_method('DoExpressCheckoutPayment');
// set base params
$this->add_parameters(array('TOKEN' => $order->paypal_express_token, 'PAYERID' => !empty($order->paypal_express_payer_id) ? $order->paypal_express_payer_id : null, 'BUTTONSOURCE' => 'WooThemes_Cart', 'RETURNFMFDETAILS' => 1));
$order_subtotal = $i = 0;
$order_items = array();
// add line items
foreach ($order->get_items() as $item) {
$product = new WC_Product($item['product_id']);
$order_items[] = array('NAME' => SV_WC_Helper::str_truncate(html_entity_decode($product->get_title(), ENT_QUOTES, 'UTF-8'), 127), 'DESC' => $this->get_item_description($item, $product), 'AMT' => $order->get_item_subtotal($item), 'QTY' => !empty($item['qty']) ? absint($item['qty']) : 1, 'ITEMURL' => $product->get_permalink());
$order_subtotal += $item['line_total'];
}
// add fees
foreach ($order->get_fees() as $fee) {
$order_items[] = array('NAME' => SV_WC_Helper::str_truncate($fee['name'], 127), 'AMT' => $fee['line_total'], 'QTY' => 1);
$order_subtotal += $fee['line_total'];
}
if (SV_WC_Plugin_Compatibility::is_wc_version_gte_2_3()) {
// WC 2.3+, no after-tax discounts
if ($order->get_total_discount() > 0) {
$order_items[] = array('NAME' => __('Total Discount', WC_Paypal_Express::TEXT_DOMAIN), 'QTY' => 1, 'AMT' => -$order->get_total_discount());
}
} else {
// WC 2.2 or lesser
// add cart discounts as line item
if ($order->get_cart_discount() > 0) {
$order_items[] = array('NAME' => __('Cart Discount', WC_Paypal_Express::TEXT_DOMAIN), 'QTY' => 1, 'AMT' => -$order->get_cart_discount());
}
// add order discounts as line item
if ($order->get_order_discount() > 0) {
$order_items[] = array('NAME' => __('Order Discount', WC_Paypal_Express::TEXT_DOMAIN), 'QTY' => 1, 'AMT' => -$order->get_order_discount());
}
}
$total_discount = SV_WC_Plugin_Compatibility::is_wc_version_gte_2_3() ? 0 : $order->get_order_discount();
// order subtotal includes pre-tax discounts in 2.3
if ($this->skip_line_items($order)) {
$item_names = array();
foreach ($order_items as $item) {
$item_names[] = sprintf('%s x %s', $item['NAME'], $item['QTY']);
}
// add a single item for the entire order
$this->add_line_item_parameters(array('NAME' => sprintf(__('%s - Order', WC_PayPal_Express::TEXT_DOMAIN), get_option('blogname')), 'DESC' => SV_WC_Helper::str_truncate(html_entity_decode(implode(', ', $item_names), ENT_QUOTES, 'UTF-8'), 127), 'AMT' => $order_subtotal - $total_discount + $order->get_cart_tax(), 'QTY' => 1), 0);
// add order-level parameters
// - Do not sent the TAXAMT due to rounding errors
$this->add_payment_parameters(array('AMT' => $order->get_total(), 'CURRENCYCODE' => $order->get_order_currency(), 'ITEMAMT' => $order_subtotal - $total_discount + $order->get_cart_tax(), 'SHIPPINGAMT' => $order->get_total_shipping() + $order->get_shipping_tax(), 'INVNUM' => $order->paypal_express_invoice_prefix . SV_WC_Helper::str_to_ascii(ltrim($order->get_order_number(), _x('#', 'hash before the order number', WC_PayPal_Express::TEXT_DOMAIN))), 'PAYMENTACTION' => $type, 'PAYMENTREQUESTID' => $order->id));
} else {
// add individual order items
foreach ($order_items as $item) {
$this->add_line_item_parameters($item, $i++);
}
// add order-level parameters
$this->add_payment_parameters(array('AMT' => $order->get_total(), 'CURRENCYCODE' => $order->get_order_currency(), 'ITEMAMT' => $order_subtotal - $total_discount, 'SHIPPINGAMT' => $order->get_total_shipping(), 'TAXAMT' => $order->get_total_tax(), 'INVNUM' => $order->paypal_express_invoice_prefix . SV_WC_Helper::str_to_ascii(ltrim($order->get_order_number(), _x('#', 'hash before the order number', WC_PayPal_Express::TEXT_DOMAIN))), 'PAYMENTACTION' => $type, 'PAYMENTREQUESTID' => $order->id));
}
}