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


PHP WC_Product_Variation::get_image方法代码示例

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


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

示例1: woocommerce_add_order_item

/**
 * Add order item via ajax
 *
 * @access public
 * @return void
 */
function woocommerce_add_order_item()
{
    global $woocommerce, $wpdb;
    check_ajax_referer('add-order-item', 'security');
    $index = trim(stripslashes($_POST['index']));
    $item_to_add = trim(stripslashes($_POST['item_to_add']));
    $post = '';
    // Find the item
    if (is_numeric($item_to_add)) {
        $post = get_post($item_to_add);
    }
    if (!$post || $post->post_type !== 'product' && $post->post_type !== 'product_variation') {
        $post_id = $wpdb->get_var($wpdb->prepare("\r\n\t\t\tSELECT post_id\r\n\t\t\tFROM {$wpdb->posts}\r\n\t\t\tLEFT JOIN {$wpdb->postmeta} ON ({$wpdb->posts}.ID = {$wpdb->postmeta}.post_id)\r\n\t\t\tWHERE {$wpdb->postmeta}.meta_key = '_sku'\r\n\t\t\tAND {$wpdb->posts}.post_status = 'publish'\r\n\t\t\tAND {$wpdb->posts}.post_type = 'shop_product'\r\n\t\t\tAND {$wpdb->postmeta}.meta_value = %s\r\n\t\t\tLIMIT 1\r\n\t\t"), $item_to_add);
        $post = get_post($post_id);
    }
    if (!$post || $post->post_type !== 'product' && $post->post_type !== 'product_variation') {
        die;
    }
    if ($post->post_type == "product") {
        $_product = new WC_Product($post->ID);
    } else {
        $_product = new WC_Product_Variation($post->ID);
    }
    ?>
	<tr class="item" rel="<?php 
    echo $index;
    ?>
">
		<td class="thumb">
			<a href="<?php 
    echo esc_url(admin_url('post.php?post=' . $_product->id . '&action=edit'));
    ?>
" class="tips" data-tip="<?php 
    echo '<strong>' . __('Product ID:', 'woocommerce') . '</strong> ' . $_product->id;
    echo '<br/><strong>' . __('Variation ID:', 'woocommerce') . '</strong> ';
    if (isset($_product->variation_id) && $_product->variation_id) {
        echo $_product->variation_id;
    } else {
        echo '-';
    }
    echo '<br/><strong>' . __('Product SKU:', 'woocommerce') . '</strong> ';
    if ($_product->sku) {
        echo $_product->sku;
    } else {
        echo '-';
    }
    ?>
"><?php 
    echo $_product->get_image();
    ?>
</a>
		</td>
		<td class="sku" width="1%">
			<?php 
    if ($_product->sku) {
        echo $_product->sku;
    } else {
        echo '-';
    }
    ?>
			<input type="hidden" class="item_id" name="item_id[<?php 
    echo $index;
    ?>
]" value="<?php 
    echo esc_attr($_product->id);
    ?>
" />
			<input type="hidden" name="item_name[<?php 
    echo $index;
    ?>
]" value="<?php 
    echo esc_attr($_product->get_title());
    ?>
" />
			<input type="hidden" name="item_variation[<?php 
    echo $index;
    ?>
]" value="<?php 
    if (isset($_product->variation_id)) {
        echo $_product->variation_id;
    }
    ?>
" />
		</td>
		<td class="name">

			<div class="row-actions">
				<span class="trash"><a class="remove_row" href="#"><?php 
    _e('Delete item', 'woocommerce');
    ?>
</a> | </span>
				<span class="view"><a href="<?php 
    echo esc_url(admin_url('post.php?post=' . $_product->id . '&action=edit'));
    ?>
//.........这里部分代码省略.........
开发者ID:vjdesign,项目名称:fontaine,代码行数:101,代码来源:woocommerce-ajax.php

示例2: printPage


//.........这里部分代码省略.........
								</thead>
								<tbody>
							
	    <?php 
                            $args = array('post_type' => 'product_variation', 'post_status' => 'publish', 'posts_per_page' => -1, 'orderby' => 'title', 'order' => 'ASC');
                            //	Loop Product Variation
                            $loop = new WP_Query($args);
                            while ($loop->have_posts()) {
                                $loop->the_post();
                                $product = new WC_Product_Variation($loop->post->ID);
                                $attrs = array();
                                if ($product->variation_data != "") {
                                    $terms = wc_get_attribute_taxonomies();
                                    foreach ($terms as $term) {
                                        $termMap['attribute_pa_' . $term->attribute_name] = $term->attribute_label;
                                    }
                                    foreach ($product->variation_data as $attributeKey => $value) {
                                        if (isset($termMap[$attributeKey])) {
                                            $attrs[] = $termMap[$attributeKey] . " : " . $value;
                                        } else {
                                            $attrs[] = $value;
                                        }
                                    }
                                }
                                /*
                                   $colore = get_post_meta( get_the_ID(), 'attribute_pa_color', true );
                                
                                   $taglia = get_post_meta( get_the_ID(), 'attribute_pa_taglia', true );
                                */
                                ?>
                 
									<tr class="order">
<td  class="thumb column-thumb" ><?php 
                                echo $product->get_image($size = 'shop_thumbnail');
                                ?>
</td>
				<td class="order-number" style="text-transform:uppercase"><?php 
                                echo $product->get_title();
                                ?>
</td>
				<td class="order-number"><?php 
                                echo get_the_title($loop->post->post_parent);
                                ?>
</td>
				<td class="order-number"><?php 
                                echo $product->sku;
                                ?>
 </td>
                <td class="order-number"><?php 
                                echo $product->regular_price;
                                ?>
 <strong>€</strong></td>
                <td class="order-number" style="color:#F00"><?php 
                                echo $product->sale_price;
                                ?>
</td>				                
                <td class="order-number" style="text-transform:uppercase"><?php 
                                echo join("<strong> / </strong>", $attrs);
                                ?>
</td>
				<td class="order-number"><?php 
                                echo $product->stock;
                                ?>
 <strong>pezzi</strong></td>
                
                <td style="float:right;" class="order-number"><?php 
开发者ID:sawan34,项目名称:tanzi,代码行数:67,代码来源:alter-inventory.php


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