• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP wc_get_product函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中wc_get_product函数的典型用法代码示例。如果您正苦于以下问题:PHP wc_get_product函数的具体用法?PHP wc_get_product怎么用?PHP wc_get_product使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: update_orders_value

	public static function update_orders_value( $post_id, $post ) {
		if ( is_int( wp_is_post_revision( $post_id ) ) ) return;
		if ( is_int( wp_is_post_autosave( $post_id ) ) ) return;
		if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) return $post_id;
		if ( ! current_user_can( 'edit_post', $post_id ) ) return $post_id;
		if ( $post->post_type != 'product' ) return $post_id;
		
		if ( version_compare( WC()->version, '2.2.0', '<' ) ) {
			$product 	= get_product( $post );
		} else {
			$product 	= wc_get_product( $post );
		}
		if ( $product ) {
			if ( $product->is_on_sale() ) {
				update_post_meta( $post_id, '_psad_onsale_order', 2 );
			} else {
				update_post_meta( $post_id, '_psad_onsale_order', 1 );
			}
			if ( $product->is_featured() ) {
				update_post_meta( $post_id, '_psad_featured_order', 2 );
			} else {
				update_post_meta( $post_id, '_psad_featured_order', 1 );	
			}
		}
	}
开发者ID:helloworld-digital,项目名称:katemorgan,代码行数:25,代码来源:class-wc-psad-functions.php


示例2: add_est_simple_field

 public function add_est_simple_field($post_id)
 {
     global $post, $thepostid, $product;
     $thepostid = $post->ID;
     $product = wc_get_product($thepostid);
     $get_value = 'eddwc_get_';
     $get_value .= $product->get_type();
     echo '<div class="options_group show_if_simple hide_if_external show_if_variable">';
     $type = eddwc_option('display_type');
     $field_type = 'number';
     $fieldClass = '';
     $custom_attributes = '';
     $value = $get_value($thepostid);
     if ($type == 'general_date') {
         $field_type = 'hidden';
         $custom_attributes = array('date-type' => 'range_select');
     } else {
         if ($value != '') {
             $value = explode(',', $value);
             if (isset($value[0]) && isset($value[1]) && $value[0] > $value[1]) {
                 $value = $value[0];
             } else {
                 if (isset($value[0]) && !isset($value[1])) {
                     $value = $value[0];
                 } else {
                     $value = $value[1];
                 }
             }
         }
     }
     woocommerce_wp_text_input(array('id' => EDDWCP_METAKEY, 'label' => __('Est. Dispatch Date:', EDDWC_TXT), 'placeholder' => __('number', EDDWC_TXT), 'type' => $field_type, 'wrapper_class' => $fieldClass, 'value' => $value, 'custom_attributes' => $custom_attributes));
     echo '</div>';
 }
开发者ID:technofreaky,项目名称:estimated-dispatch-date-woocommerce,代码行数:33,代码来源:class-admin-product-settings.php


示例3: output

    public static function output()
    {
        global $post, $thepostid;
        $thepostid = $post->ID;
        $_product = wc_get_product($thepostid);
        $terms = array();
        $delivery_time = $_product->gzd_product->delivery_time;
        woocommerce_wp_select(array('id' => '_unit', 'label' => __('Unit', 'woocommerce-germanized'), 'options' => array_merge(array('none' => __('Select unit', 'woocommerce-germanized')), WC_germanized()->units->get_units()), 'desc_tip' => true, 'description' => __('Needed if selling on a per unit basis', 'woocommerce-germanized')));
        woocommerce_wp_text_input(array('id' => '_unit_base', 'label' => __('Unit Base', 'woocommerce-germanized'), 'data_type' => 'decimal', 'desc_tip' => true, 'description' => __('Unit price per amount (e.g. 100)', 'woocommerce-germanized')));
        woocommerce_wp_text_input(array('id' => '_unit_price_regular', 'label' => __('Regular Unit Price', 'woocommerce-germanized') . ' (' . get_woocommerce_currency_symbol() . ')', 'data_type' => 'price'));
        woocommerce_wp_text_input(array('id' => '_unit_price_sale', 'label' => __('Sale Unit Price', 'woocommerce-germanized') . ' (' . get_woocommerce_currency_symbol() . ')', 'data_type' => 'price'));
        if (version_compare(WC()->version, '2.3', '<')) {
            return;
        }
        ?>
		
		<p class="form-field">
			<label for="delivery_time"><?php 
        _e('Delivery Time', 'woocommerce-germanized');
        ?>
</label>
			<input type="hidden" class="wc-product-search wc-gzd-delivery-time-search" style="width: 50%" id="delivery_time" name="delivery_time" data-minimum_input_length="1" data-allow_clear="true" data-placeholder="<?php 
        _e('Search for a delivery time&hellip;', 'woocommerce-germanized');
        ?>
" data-action="woocommerce_gzd_json_search_delivery_time" data-multiple="false" data-selected="<?php 
        echo $delivery_time ? $delivery_time->name : '';
        ?>
" value="<?php 
        echo $delivery_time ? $delivery_time->term_id : '';
        ?>
" />
		</p>
		
		<?php 
    }
开发者ID:radscheit,项目名称:unicorn,代码行数:35,代码来源:class-wc-gzd-meta-box-product-data.php


示例4: add_order_item

 /**
  * Add order item via ajax
  * exact copy from /wp-content/plugins/woocommerce/includes/class-wc-ajax.php, with change to template selection
  */
 public static function add_order_item()
 {
     check_ajax_referer('order-item', 'security');
     $item_to_add = sanitize_text_field($_POST['item_to_add']);
     $order_id = absint($_POST['order_id']);
     // Find the item
     if (!is_numeric($item_to_add)) {
         die;
     }
     $post = get_post($item_to_add);
     if (!$post || 'product' !== $post->post_type && 'product_variation' !== $post->post_type) {
         die;
     }
     $_product = wc_get_product($post->ID);
     $order = wc_get_order($order_id);
     $order_taxes = $order->get_taxes();
     $class = 'new_row';
     // Set values
     $item = array();
     $item['product_id'] = $_product->id;
     $item['variation_id'] = isset($_product->variation_id) ? $_product->variation_id : '';
     $item['variation_data'] = isset($_product->variation_data) ? $_product->variation_data : '';
     $item['name'] = $_product->get_title();
     $item['tax_class'] = $_product->get_tax_class();
     $item['qty'] = 1;
     $item['line_subtotal'] = wc_format_decimal($_product->get_price_excluding_tax());
     $item['line_subtotal_tax'] = '';
     $item['line_total'] = wc_format_decimal($_product->get_price_excluding_tax());
     $item['line_tax'] = '';
     // Add line item
     $item_id = wc_add_order_item($order_id, array('order_item_name' => $item['name'], 'order_item_type' => 'line_item'));
     // Add line item meta
     if ($item_id) {
         wc_add_order_item_meta($item_id, '_qty', $item['qty']);
         wc_add_order_item_meta($item_id, '_tax_class', $item['tax_class']);
         wc_add_order_item_meta($item_id, '_product_id', $item['product_id']);
         wc_add_order_item_meta($item_id, '_variation_id', $item['variation_id']);
         wc_add_order_item_meta($item_id, '_line_subtotal', $item['line_subtotal']);
         wc_add_order_item_meta($item_id, '_line_subtotal_tax', $item['line_subtotal_tax']);
         wc_add_order_item_meta($item_id, '_line_total', $item['line_total']);
         wc_add_order_item_meta($item_id, '_line_tax', $item['line_tax']);
         // Since 2.2
         wc_add_order_item_meta($item_id, '_line_tax_data', array('total' => array(), 'subtotal' => array()));
         // Store variation data in meta
         if ($item['variation_data'] && is_array($item['variation_data'])) {
             foreach ($item['variation_data'] as $key => $value) {
                 wc_add_order_item_meta($item_id, str_replace('attribute_', '', $key), $value);
             }
         }
         do_action('woocommerce_ajax_add_order_item_meta', $item_id, $item);
     }
     $item = apply_filters('woocommerce_ajax_order_item', $item, $item_id);
     //include( 'admin/meta-boxes/views/html-order-item.php' );
     //@@@@LOUSHOU - allow overtake of template
     include apply_filters('qsot-woo-template', 'meta-boxes/views/html-order-item.php', 'admin');
     // Quit out
     die;
 }
开发者ID:Jayriq,项目名称:opentickets-community,代码行数:62,代码来源:admin-ajax.class.php


示例5: get_settings

 /**
  * Get settings array
  *
  * @return array
  */
 public function get_settings()
 {
     $values = WC_Order_Simulator::get_settings();
     // selected products
     $product_ids = array_filter(array_map('absint', $values['products']));
     $json_ids = array();
     foreach ($product_ids as $product_id) {
         $product = wc_get_product($product_id);
         if (is_object($product)) {
             $json_ids[$product_id] = wp_kses_post(html_entity_decode($product->get_formatted_name(), ENT_QUOTES, get_bloginfo('charset')));
         }
     }
     $data_selected = esc_attr(json_encode($json_ids));
     $data_value = implode(',', array_keys($json_ids));
     $next_scheduled = wp_next_scheduled('wcos_create_orders');
     if (!$next_scheduled) {
         $message = 'Schedule not found. Please deactivate then activate the plugin to fix the scheduler.';
     } else {
         $format = get_option('date_format') . ' ' . get_option('time_format');
         $now = date($format, current_time('timestamp', true));
         $message = 'Current time: <code>' . $now . ' GMT</code><br/>Next run: <code>' . date(get_option('date_format') . ' ' . get_option('time_format'), $next_scheduled) . ' GMT</code>';
     }
     $settings = apply_filters('woocommerce_order_simulator_settings', array(array('title' => __('Settings', 'woocommerce'), 'type' => 'title', 'desc' => $message, 'id' => 'wcos_settings'), array('title' => __('Orders per Hour', 'woocommerce'), 'desc' => __('The maximum number of orders to generate per hour.', 'woocommerce'), 'id' => 'wcos_orders_per_hour', 'css' => 'width:100px;', 'default' => $values['orders_per_hour'], 'type' => 'number', 'desc_tip' => true), array('title' => __('Products', 'woocommerce'), 'desc' => __('The products that will be added to the generated orders. Leave empty to randomly select from all products.', 'woocommerce'), 'id' => 'wcos_products', 'default' => $data_value, 'type' => 'text', 'class' => 'wc-product-search', 'css' => 'min-width: 350px;', 'custom_attributes' => array('data-multiple' => "true", 'data-selected' => $data_selected), 'desc_tip' => true), array('title' => __('Min Order Products', 'woocommerce'), 'id' => 'wcos_min_order_products', 'desc' => __('The minimum number of products to add to the generated orders', 'woocommerce'), 'type' => 'number', 'custom_attributes' => array('min' => 1), 'default' => $values['min_order_products'], 'css' => 'width:50px;', 'autoload' => false), array('title' => __('Max Order Products', 'woocommerce'), 'desc' => '', 'id' => 'wcos_max_order_products', 'desc' => __('The maximum number of products to add to the generated orders', 'woocommerce'), 'type' => 'number', 'custom_attributes' => array('min' => 1), 'default' => $values['max_order_products'], 'css' => 'width:50px;', 'autoload' => false), array('title' => __('Create User Accounts', 'woocommerce'), 'desc_tip' => true, 'id' => 'wcos_create_users', 'desc' => __('If enabled, accounts will be created and will randomly assigned to new orders.', 'woocommerce'), 'type' => 'select', 'options' => array(0 => __('No - assign existing accounts to new orders', 'woocommerce'), 1 => __('Yes - create a new account or randomly select an existing account to assign to new orders', 'woocommerce')), 'default' => $values['create_users'], 'autoload' => false, 'class' => 'wc-enhanced-select'), array('title' => __('Completed Order Status Chance', 'woocommerce'), 'desc_tip' => false, 'id' => 'wcos_order_completed_pct', 'desc' => __('%', 'woocommerce'), 'type' => 'number', 'default' => $values['order_completed_pct'], 'autoload' => false, 'css' => 'width:50px;', 'custom_attributes' => array('min' => 0, 'max' => 100)), array('title' => __('Processing Order Status Chance', 'woocommerce'), 'desc_tip' => false, 'id' => 'wcos_order_processing_pct', 'desc' => __('%', 'woocommerce'), 'type' => 'number', 'default' => $values['order_processing_pct'], 'autoload' => false, 'css' => 'width:50px;', 'custom_attributes' => array('min' => 0, 'max' => 100)), array('title' => __('Failed Order Status Chance', 'woocommerce'), 'desc_tip' => false, 'id' => 'wcos_order_failed_pct', 'desc' => __('%', 'woocommerce'), 'type' => 'number', 'default' => $values['order_failed_pct'], 'autoload' => false, 'css' => 'width:50px;', 'custom_attributes' => array('min' => 0, 'max' => 100)), array('type' => 'sectionend', 'id' => 'wcos_settings')));
     return apply_filters('woocommerce_get_settings_' . $this->id, $settings);
 }
开发者ID:75nineteen,项目名称:order-simulator-woocommerce,代码行数:30,代码来源:class-wc-settings-order-simulator.php


示例6: gather_products_data

 public function gather_products_data(&$products_info)
 {
     //return array();
     $args = array('post_type' => 'product', 'posts_per_page' => -1);
     $loop = new WP_Query($args);
     if ($loop->have_posts()) {
         while ($loop->have_posts()) {
             $loop->the_post();
             $the_ID = get_the_ID();
             //$the_product = new WC_Product( $the_ID );
             $the_product = wc_get_product($the_ID);
             $the_price = $the_product->get_price();
             $the_stock = $the_product->get_total_stock();
             //if ( 0 == $the_stock )
             //$the_stock = get_post_meta( $the_ID, '_stock', true );
             $the_title = get_the_title();
             $the_date = get_the_date();
             $the_permalink = get_the_permalink();
             $post_custom = get_post_custom($the_ID);
             $total_sales = isset($post_custom['total_sales'][0]) ? $post_custom['total_sales'][0] : 0;
             //$available_variations = $the_product->get_available_variations();
             $purchase_price = wc_get_product_purchase_price($the_ID);
             $sales_in_day_range = array();
             foreach ($this->ranges_in_days as $the_range) {
                 $sales_in_day_range[$the_range] = 0;
             }
             $products_info[$the_ID] = array('ID' => $the_ID, 'title' => $the_title, 'permalink' => $the_permalink, 'price' => $the_price, 'stock' => $the_stock, 'stock_price' => $the_price * $the_stock, 'total_sales' => $total_sales, 'date_added' => $the_date, 'purchase_price' => $purchase_price, 'last_sale' => 0, 'sales_in_period' => $sales_in_day_range);
         }
     }
 }
开发者ID:quasel,项目名称:woocommerce-jetpack,代码行数:30,代码来源:wcj-class-reports-stock.php


示例7: wcs_is_product_switchable_type

/**
 * Checks if a given product is of a switchable type
 *
 * @param int|WC_Product $product A WC_Product object or the ID of a product to check
 * @return bool
 * @since  2.0
 */
function wcs_is_product_switchable_type($product)
{
    if (!is_object($product)) {
        $product = wc_get_product($product);
    }
    $variation = null;
    if (empty($product)) {
        $is_product_switchable = false;
    } else {
        // back compat for parent products
        if ($product->is_type('subscription_variation') && !empty($product->parent)) {
            $variation = $product;
            $product = $product->parent;
        }
        $allow_switching = get_option(WC_Subscriptions_Admin::$option_prefix . '_allow_switching', 'no');
        switch ($allow_switching) {
            case 'variable':
                $is_product_switchable = $product->is_type(array('variable-subscription', 'subscription_variation')) ? true : false;
                break;
            case 'grouped':
                $is_product_switchable = 0 !== $product->post->post_parent ? true : false;
                break;
            case 'variable_grouped':
                $is_product_switchable = $product->is_type(array('variable-subscription', 'subscription_variation')) || 0 !== $product->post->post_parent ? true : false;
                break;
            case 'no':
            default:
                $is_product_switchable = false;
                break;
        }
    }
    return apply_filters('wcs_is_product_switchable', $is_product_switchable, $product, $variation);
}
开发者ID:DustinHartzler,项目名称:TheCLEFT,代码行数:40,代码来源:wcs-switch-functions.php


示例8: getHtmlIngredientes

/**
 * DEVUELVE EL HTML DE LOS INGREDIENTES
 */
function getHtmlIngredientes($ingredientes, $producto_id)
{
    $html = '<h2 class="[ text-center color-dark ][ no-margin--top ]">' . get_the_title($producto_id) . '</h2>';
    $html .= '<div class="[ row ]">';
    if (!empty($ingredientes)) {
        foreach ($ingredientes as $key => $ingrediente) {
            $html .= '<div class="[ col-xs-3 col-md-2 ]">';
            $html .= '<a class="[ box-content ]" href="' . site_url('/recetas/') . '?ingrediente=' . $ingrediente->ingrediente_id . '">';
            $url_img = attachment_image_url($ingrediente->ingrediente_id, 'medium');
            $html .= '<img class="[ image-responsive ]" alt="" src="' . $url_img . '">';
            $html .= '<p class="[ text-center ]">' . get_the_title($ingrediente->ingrediente_id) . '</p>';
            $html .= '</a>';
            $html .= '</div>';
        }
    }
    $html .= '</div>';
    $producto = wc_get_product($producto_id);
    $variations = $producto->get_available_variations();
    $addToCart = '';
    $costoVariationSemanal = 0;
    $costoTotal = 0;
    $html .= '<div class="[ card__radio-options ][ text-center color-dark ]">';
    $html .= '<div class="[ radio-options__label ]">';
    $html .= 'Entregas semanales durante:';
    $html .= '</div>';
    if (!empty($variations)) {
        $count = 1;
        foreach ($variations as $variation) {
            $name = getNameVariation($variation['variation_id']);
            $check = $count == 1 ? 'checked' : '';
            $nombreVariacion = getNameOriginVariation($variation['variation_id']);
            $cansatSemanal = getCostoCanastaTemporalidad($nombreVariacion, $variation['display_price']);
            if ($count == 1) {
                $addToCart = site_url('/mi-carrito/?add-to-cart=') . $variation['variation_id'];
                $costoVariationSemanal = $cansatSemanal;
                $costoTotal = $variation['display_price'];
            }
            $html .= '<label class="[ radio-options__selector__label ]" for="c9_meals-' . $variation['variation_id'] . '">';
            $html .= '<input ';
            $html .= 'id="c9_meals-' . $variation['variation_id'] . '"';
            $html .= 'data-costo="' . number_format($variation['display_price']) . '"';
            $html .= 'data-producto="' . $producto_id . '"';
            $html .= 'data-variacion="' . $variation['variation_id'] . '"';
            $html .= 'data-semanal="' . $cansatSemanal . '"';
            $html .= 'class="[ radio-options__selector ][ check-compra-modal ]" ';
            $html .= 'type="radio"';
            $html .= 'name="variaciones-00' . $producto_id . '"';
            $html .= 'value="c9"';
            $html .= $check;
            $html .= '>' . $name;
            $html .= '</label>';
            $count++;
        }
    }
    $html .= '</div>';
    $html .= '<div class="text-center">';
    $html .= '<a class="[ btn btn-secondary ] url-add-cart-product-modal-00' . $producto_id . '" href="' . $addToCart . '">Añadir al carrito</a>';
    $html .= '</div>';
    return $html;
}
开发者ID:pcuervo,项目名称:wp-yolcan,代码行数:63,代码来源:function-productos.php


示例9: post_downloads

 /**
  * @param $product_id
  * @param $downloads
  * @return $files (all product downloads)
  */
 static function post_downloads($product_id, $downloads)
 {
     // $filename should be the path to a file in the upload directory.
     // example $filename = 'woocommerce_uploads/2015/07/aka_Matrix42_Tool_CleanDatabase_7.2.1.20150625.aka.zip';
     $downloads = json_decode($downloads);
     // Get all existing post downloads and add the new passed downloads
     $files = array();
     $result_all_files = array();
     $wc_product = wc_get_product($product_id);
     $untyped_array_of_downloads = $wc_product->get_files();
     foreach ($untyped_array_of_downloads as $download_key => $download_value) {
         // Add existing download to the $files array
         $existing_download = (object) $download_value;
         $files[md5($existing_download->file)] = array('name' => $existing_download->name, 'file' => $existing_download->file);
     }
     foreach ($downloads as $key => $new_download) {
         // Add the new downloads to the existing post downloads
         $files[md5($new_download->file)] = array('name' => $new_download->name, 'file' => $new_download->file);
     }
     // Update product post meta (_downloadable_files)
     update_post_meta($product_id, '_downloadable_files', $files);
     // Collect downloads just for function result
     foreach ($files as $key => $download) {
         array_push($result_all_files, $download);
     }
     return $result_all_files;
 }
开发者ID:akarimgh,项目名称:matrix42-slim-api,代码行数:32,代码来源:class-matrix42-product.php


示例10: wdm_add_custom_settings

function wdm_add_custom_settings()
{
    global $woocommerce, $post;
    print_r(wc_get_product($post));
    echo '<script>
    jQuery(document).ready(function($) {
        $("#datepicker").datepicker();
    });
</script>';
    echo ' <div class="options_group show_if_willow_prod_2"><div id="datepicker"></div>
    <input type="hidden" name="tipo" value="pre-produto">';
    // Create a number field, for example for UPC
    // woocommerce_wp_text_input(
    //   array(
    //    'id'                => 'dias_envio',
    //    'label'             => __( 'Dias para o envio', 'woocommerce' ),
    //    'placeholder'       => '',
    //    'desc_tip'    => 'true',
    //    'description'       => __( 'Digite o numero de dias ', 'woocommerce' ),
    //    'type'              => 'number'
    //    ));
    // // Create a checkbox for product purchase status
    //   woocommerce_wp_checkbox(
    //    array(
    //    'id'            => 'wdm_is_purchasable',
    //    'label'         => __('Is Purchasable', 'woocommerce' )
    //    ));
    echo '</div>';
}
开发者ID:willowmagrini,项目名称:dg,代码行数:29,代码来源:pre-venda-old.php


示例11: post_attachment

 static function post_attachment($download, $product_id)
 {
     // $filename should be the path to a file in the upload directory.
     // example $filename = 'woocommerce_uploads/2015/07/aka_Matrix42_Tool_CleanDatabase_7.2.1.20150625.aka.zip';
     $download = json_decode($download);
     $filename = $download->file;
     $web_url = $download->web_url;
     $wp_upload_dir = wp_upload_dir();
     $file = $wp_upload_dir['path'] . '/' . $filename;
     //Check the type of file. We'll use this as the 'post_mime_type'.
     $filetype = wp_check_filetype(basename($file), null);
     $attachment = array('guid' => $wp_upload_dir['url'] . '/' . basename($file), 'post_mime_type' => $filetype['type'], 'post_title' => preg_replace('/\\.[^.]+$/', '', basename($file)), 'post_content' => '', 'post_status' => 'inherit');
     // Insert the attachment.
     $attach_id = wp_insert_attachment($attachment, $file, $product_id);
     // Make sure that this file is included, as wp_generate_attachment_metadata() depends on it.
     require_once ABSPATH . 'wp-admin/includes/image.php';
     // Generate the metadata for the attachment, and update the database record.
     $attach_data = wp_generate_attachment_metadata($attach_id, $file);
     wp_update_attachment_metadata($attach_id, $attach_data);
     // Get all existing post downloads and
     $files = array();
     $wc_product = wc_get_product($product_id);
     $untyped_array_of_downloads = $wc_product->get_files();
     foreach ($untyped_array_of_downloads as $download_key => $download_value) {
         $download_name = $download_value['name'];
         $download_url = $download_value['file'];
         $files[md5($download_url)] = array('name' => $download_name, 'file' => $download_url);
     }
     // Extend the existing post downloads by the new one
     $files[md5($download_url)] = array('name' => $filename, 'file' => $web_url);
     // Update post meta (_downloadable_files)
     update_post_meta($product_id, '_downloadable_files', $files);
     return 1;
 }
开发者ID:akarimgh,项目名称:matrix42-slim-api,代码行数:34,代码来源:class-matrix42-attachment.php


示例12: column_default

    /**
     * column_default function.
     *
     * @access public
     * @param mixed $post
     * @param mixed $column_name
     */
    public function column_default($item, $column_name)
    {
        global $wpdb;
        switch ($column_name) {
            case 'product_id':
                $product = wc_get_product($item->product_id);
                return $product ? '<a href="' . admin_url('post.php?post=' . absint($product->id) . '&action=edit') . '">' . esc_html($product->get_title()) . '</a>' : __('n/a', 'wp-job-manager-wc-paid-listings');
            case 'user_id':
                $user = get_user_by('id', $item->user_id);
                if ($item->user_id && $user) {
                    return '<a href="' . admin_url('user-edit.php?user_id=' . absint($item->user_id)) . '">' . esc_attr($user->display_name) . '</a><br/><span class="description">' . esc_html($user->user_email) . '</span>';
                } else {
                    return __('n/a', 'wp-job-manager-wc-paid-listings');
                }
            case 'order_id':
                return $item->order_id > 0 ? '<a href="' . admin_url('post.php?post=' . absint($item->order_id) . '&action=edit') . '">#' . absint($item->order_id) . ' &rarr;</a>' : __('n/a', 'wp-job-manager-wc-paid-listings');
            case 'featured_job':
                return $item->package_featured ? '&#10004;' : '&ndash;';
            case 'duration':
                return $item->package_duration ? sprintf(__('%d Days', 'wp-job-manager-wc-paid-listings'), absint($item->package_duration)) : '&ndash;';
            case 'limit':
                return '<a href="' . esc_url(admin_url('edit.php?post_type=' . ('resume' === $item->package_type ? 'resume' : 'job_listing') . '&package=' . absint($item->id))) . '">' . ($item->package_limit ? sprintf(__('%s Posted', 'wp-job-manager-wc-paid-listings'), absint($item->package_count) . ' / ' . absint($item->package_limit)) : __('Unlimited', 'wp-job-manager-wc-paid-listings')) . '</a>';
            case 'package_type':
                return 'resume' === $item->package_type ? __('Resume Package', 'wp-job-manager-wc-paid-listings') : __('Job Package', 'wp-job-manager-wc-paid-listings');
            case 'job_actions':
                return '<div class="actions">
					<a class="button button-icon icon-edit" href="' . esc_url(add_query_arg(array('action' => 'edit', 'package_id' => $item->id), admin_url('users.php?page=wc_paid_listings_packages'))) . '">' . __('Edit', 'wp-job-manager-wc-paid-listings') . '</a>
					<a class="button button-icon icon-delete" href="' . wp_nonce_url(add_query_arg(array('action' => 'delete', 'package_id' => $item->id), admin_url('users.php?page=wc_paid_listings_packages')), 'delete', 'delete_nonce') . '">' . __('Delete', 'wp-job-manager-wc-paid-listings') . '</a></div>
				</div>';
        }
    }
开发者ID:sabdev1,项目名称:sabstaff,代码行数:38,代码来源:class-wc-paid-listings-admin-packages.php


示例13: init_atts

 /**
  * Inits shortcode atts and properties.
  *
  * @version 2.5.4
  * @since   2.5.4
  * @param   array $atts Shortcode atts.
  * @return  array The (modified) shortcode atts.
  */
 function init_atts($atts)
 {
     // Atts
     if (0 == $atts['product_id']) {
         global $wcj_product_id_for_shortcode;
         if (0 != $wcj_product_id_for_shortcode) {
             $atts['product_id'] = $wcj_product_id_for_shortcode;
         } else {
             $atts['product_id'] = get_the_ID();
         }
         if (0 == $atts['product_id']) {
             return false;
         }
     }
     $the_post_type = get_post_type($atts['product_id']);
     if ('product' !== $the_post_type && 'product_variation' !== $the_post_type) {
         return false;
     }
     // Class properties
     $this->the_product = wc_get_product($atts['product_id']);
     if (!$this->the_product) {
         return false;
     }
     return $atts;
 }
开发者ID:algoritmika,项目名称:woocommerce-jetpack,代码行数:33,代码来源:class-wcj-products-crowdfunding-shortcodes.php


示例14: set_sku_with_variable

 /**
  * set_sku_with_variable.
  */
 function set_sku_with_variable($product_id, $is_preview)
 {
     $this->set_sku($product_id, $product_id, '', $is_preview);
     // Handling variable products
     $variation_handling = apply_filters('wcj_get_option_filter', 'as_variable', get_option('wcj_sku_variations_handling', 'as_variable'));
     $product = wc_get_product($product_id);
     if ($product->is_type('variable')) {
         $variations = $product->get_available_variations();
         if ('as_variable' === $variation_handling) {
             foreach ($variations as $variation) {
                 $this->set_sku($variation['variation_id'], $product_id, '', $is_preview);
             }
         } else {
             if ('as_variation' === $variation_handling) {
                 foreach ($variations as $variation) {
                     $this->set_sku($variation['variation_id'], $variation['variation_id'], '', $is_preview);
                 }
             } else {
                 if ('as_variable_with_suffix' === $variation_handling) {
                     $variation_suffixes = 'abcdefghijklmnopqrstuvwxyz';
                     $abc = 0;
                     foreach ($variations as $variation) {
                         $this->set_sku($variation['variation_id'], $product_id, $variation_suffixes[$abc++], $is_preview);
                         if (26 == $abc) {
                             $abc = 0;
                         }
                     }
                 }
             }
         }
     }
 }
开发者ID:ltdat287,项目名称:id.nhomdichvu,代码行数:35,代码来源:class-wcj-sku.php


示例15: widget

 /**
  * widget function.
  *
  * @see WP_Widget
  *
  * @param array $args
  * @param array $instance
  */
 public function widget($args, $instance)
 {
     global $comments, $comment;
     if ($this->get_cached_widget($args)) {
         return;
     }
     ob_start();
     $number = !empty($instance['number']) ? absint($instance['number']) : $this->settings['number']['std'];
     $comments = get_comments(array('number' => $number, 'status' => 'approve', 'post_status' => 'publish', 'post_type' => 'product'));
     if ($comments) {
         $this->widget_start($args, $instance);
         echo '<ul class="product_list_widget">';
         foreach ((array) $comments as $comment) {
             $_product = wc_get_product($comment->comment_post_ID);
             $rating = intval(get_comment_meta($comment->comment_ID, 'rating', true));
             $rating_html = $_product->get_rating_html($rating);
             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('<span class="reviewer">' . _x('by %1$s', 'by comment author', 'woocommerce') . '</span>', get_comment_author());
             echo '</li>';
         }
         echo '</ul>';
         $this->widget_end($args);
     }
     $content = ob_get_clean();
     echo $content;
     $this->cache_widget($args, $content);
 }
开发者ID:bitoncoin,项目名称:woocommerce,代码行数:38,代码来源:class-wc-widget-recent-reviews.php


示例16: restrict_by_product

    /**
     * Displays the dropdown for the product filter
     * @return string the html dropdown element
     */
    public function restrict_by_product()
    {
        global $typenow;
        if ('shop_subscription' !== $typenow) {
            return;
        }
        $product_id = '';
        $product_string = '';
        if (!empty($_GET['_wcs_product'])) {
            $product_id = absint($_GET['_wcs_product']);
            $product_string = wc_get_product($product_id)->get_formatted_name();
        }
        ?>
		<input type="hidden" class="wc-product-search" name="_wcs_product" data-placeholder="<?php 
        esc_attr_e('Search for a product&hellip;', 'woocommerce-subscriptions');
        ?>
" data-action="woocommerce_json_search_products_and_variations" data-selected="<?php 
        echo esc_attr(strip_tags($product_string));
        ?>
" value="<?php 
        echo esc_attr($product_id);
        ?>
" data-allow_clear="true" />
		<?php 
    }
开发者ID:DustinHartzler,项目名称:TheCLEFT,代码行数:29,代码来源:class-wcs-admin-post-types.php


示例17: order_paid

 /**
  * Triggered when an order is paid
  * @param  int $order_id
  */
 public function order_paid($order_id)
 {
     // Get the order
     $order = new WC_Order($order_id);
     if (get_post_meta($order_id, 'wc_paid_listings_packages_processed', true)) {
         return;
     }
     foreach ($order->get_items() as $item) {
         $product = wc_get_product($item['product_id']);
         if ($product->is_type(array('job_package', 'resume_package', 'job_package_subscription', 'resume_package_subscription')) && $order->customer_user) {
             // Give packages to user
             for ($i = 0; $i < $item['qty']; $i++) {
                 $user_package_id = wc_paid_listings_give_user_package($order->customer_user, $product->id, $order_id);
             }
             // Approve job or resume with new package
             if (isset($item['job_id'])) {
                 $job = get_post($item['job_id']);
                 if (in_array($job->post_status, array('pending_payment', 'expired'))) {
                     wc_paid_listings_approve_job_listing_with_package($job->ID, $order->customer_user, $user_package_id);
                 }
             } elseif (isset($item['resume_id'])) {
                 $resume = get_post($item['resume_id']);
                 if (in_array($resume->post_status, array('pending_payment', 'expired'))) {
                     wc_paid_listings_approve_resume_with_package($resume->ID, $order->customer_user, $user_package_id);
                 }
             }
         }
     }
     update_post_meta($order_id, 'wc_paid_listings_packages_processed', true);
 }
开发者ID:sabdev1,项目名称:sabstaff,代码行数:34,代码来源:class-wc-paid-listings-orders.php


示例18: wc_autoship_noni_pricing_current_role

 /**
  * Get autoship price for current role
  * @param double $autoship_price
  * @param int $product_id
  */
 function wc_autoship_noni_pricing_current_role($autoship_price, $product_id, $autoship_frequency, $customer_id)
 {
     if (empty($customer_id)) {
         // User is not logged in
         return $autoship_price;
     }
     // Get current user
     $user = get_user_by('id', $customer_id);
     if (!$user->ID) {
         // User is not logged in
         return $autoship_price;
     }
     // Map product prices to roles
     // sorted from lowest price to highest price
     $prices = array('F1-0001' => array('salesrep' => 35.0), 'F1-0002' => array('salesrep' => 45.0), 'F1-0004' => array('salesrep' => 0.0), 'F1-0008' => array('salesrep' => 140.0), 'F1-0009' => array('salesrep' => 180.0), 'F1-0011' => array('salesrep' => 8.0), 'F1-0012' => array('salesrep' => 12.0), 'F1-0021' => array('salesrep' => 16.0), 'F1-0022' => array('salesrep' => 20.0));
     // Get product
     $product = wc_get_product($product_id);
     $product_sku = $product->get_sku();
     if (!isset($prices[$product_sku])) {
         // No prices set, return default
         return $autoship_price;
     }
     foreach ($prices[$product_sku] as $role => $price) {
         if (in_array($role, $user->roles)) {
             // User has role
             return $price;
         }
     }
     // Default
     return $autoship_price;
 }
开发者ID:jonrules,项目名称:woocommerce-autoship-noni-pricing,代码行数:36,代码来源:woocommerce-autoship-noni-pricing.php


示例19: stock_manager_save_one_product_stock_data

/**
 * Save one product stock data 
 *
 */
function stock_manager_save_one_product_stock_data()
{
    if (current_user_can('manage_woocommerce')) {
        $product_id = sanitize_text_field($_POST['product']);
        check_ajax_referer('wsm-ajax-nonce-' . $product_id, 'secure');
        $sku = sanitize_text_field($_POST['sku']);
        $manage_stock = sanitize_text_field($_POST['manage_stock']);
        $stock_status = sanitize_text_field($_POST['stock_status']);
        $backorders = sanitize_text_field($_POST['backorders']);
        $stock = sanitize_text_field($_POST['stock']);
        $weight = sanitize_text_field($_POST['weight']);
        update_post_meta($product_id, '_sku', $sku);
        update_post_meta($product_id, '_manage_stock', $manage_stock);
        update_post_meta($product_id, '_stock_status', $stock_status);
        update_post_meta($product_id, '_backorders', $backorders);
        $_product = wc_get_product($product_id);
        //Set stock via product class
        $_product->set_stock($stock);
        if (!empty($_POST['regular_price'])) {
            $price = sanitize_text_field($_POST['regular_price']);
            if (!empty($_POST['sales_price'])) {
                $sale_price = sanitize_text_field($_POST['sales_price']);
                wsm_save_price($product_id, $price, $sale_price);
            } else {
                wsm_save_price($product_id, $price);
            }
        }
        update_post_meta($product_id, '_weight', $weight);
    }
    exit;
}
开发者ID:AndyA,项目名称:River,代码行数:35,代码来源:woocommerce-stock-manager.php


示例20: download_product


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP wc_get_product_id_by_sku函数代码示例发布时间:2022-05-23
下一篇:
PHP wc_get_price_thousand_separator函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap