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

PHP woocommerce_template_single_add_to_cart函数代码示例

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

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



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

示例1: wpb_wl_hook_quickview_content

function wpb_wl_hook_quickview_content()
{
    global $post, $woocommerce, $product;
    ?>
	<div id="wpb_wl_quick_view_<?php 
    echo get_the_id();
    ?>
" class="mfp-hide mfp-with-anim wpb_wl_quick_view_content wpb_wl_clearfix">
		<div class="wpb_wl_images">
			<?php 
    if (has_post_thumbnail()) {
        $image_title = esc_attr(get_the_title(get_post_thumbnail_id()));
        $image_link = wp_get_attachment_url(get_post_thumbnail_id());
        $image = get_the_post_thumbnail($post->ID, apply_filters('single_product_large_thumbnail_size', 'shop_single'), array('title' => $image_title));
        $attachment_count = count($product->get_gallery_attachment_ids());
        if ($attachment_count > 0) {
            $gallery = '[product-gallery]';
        } else {
            $gallery = '';
        }
        echo apply_filters('woocommerce_single_product_image_html', sprintf('<a href="%s" itemprop="image" class="woocommerce-main-image zoom" title="%s" data-rel="prettyPhoto' . $gallery . '">%s</a>', $image_link, $image_title, $image), $post->ID);
    } else {
        echo apply_filters('woocommerce_single_product_image_html', sprintf('<img src="%s" alt="%s" />', wc_placeholder_img_src(), __('Placeholder', 'woocommerce-lightbox')), $post->ID);
    }
    ?>
		</div>
		<div class="wpb_wl_summary">
			<!-- Product Title -->
			<h2 class="wpb_wl_product_title"><?php 
    the_title();
    ?>
</h2>

			<!-- Product Price -->
			<?php 
    if ($price_html = $product->get_price_html()) {
        ?>
				<span class="price wpb_wl_product_price"><?php 
        echo $price_html;
        ?>
</span>
			<?php 
    }
    ?>

			<!-- Product short description -->
			<?php 
    woocommerce_template_single_excerpt();
    ?>

			<!-- Product cart link -->
			<?php 
    woocommerce_template_single_add_to_cart();
    ?>

		</div>
	</div>
	<?php 
}
开发者ID:AndyA,项目名称:River,代码行数:59,代码来源:wpb_wl_hooks.php


示例2: nm_qv_product_summary_actions

function nm_qv_product_summary_actions()
{
    global $product, $nm_theme_options;
    $details_button_class = '';
    // Add-to-cart button
    if ($nm_theme_options['product_quickview_atc']) {
        $details_button_class = ' border';
        woocommerce_template_single_add_to_cart();
    }
    // Details button
    if ($nm_theme_options['product_quickview_details_button']) {
        echo '<a href="' . esc_url(get_permalink($product->id)) . '" class="nm-qv-details-button button' . esc_attr($details_button_class) . '">' . esc_html__('Details', 'nm-framework') . '</a>';
    }
}
开发者ID:tccyp001,项目名称:onemore-wordpress,代码行数:14,代码来源:content-quickview.php


示例3: shortcode_handler

 /**
  * Frontend Shortcode Handler
  *
  * @param array $atts array of attributes
  * @param string $content text within enclosing form of shortcode element
  * @param string $shortcodename the shortcode found, when == callback name
  * @return string $output returns the modified html string
  */
 function shortcode_handler($atts, $content = "", $shortcodename = "", $meta = "")
 {
     $output = "";
     $meta['el_class'];
     global $woocommerce, $product;
     if (!is_object($woocommerce) || !is_object($woocommerce->query) || empty($product)) {
         return;
     }
     // $product = wc_get_product();
     $output .= "<div class='av-woo-purchase-button " . $meta['el_class'] . "'>";
     ob_start();
     wc_clear_notices();
     woocommerce_template_single_add_to_cart();
     $output .= ob_get_clean();
     $output .= "</div>";
     return $output;
 }
开发者ID:erikdukker,项目名称:medisom,代码行数:25,代码来源:product_snippet_button.php


示例4: do_action

         do_action('woocommerce_product_meta_end');
         $result .= '</div>';
     }
     $result .= '</div>';
 }
 if (in_array('price', $enable) || in_array('button', $enable)) {
     $result .= '<div class="dp-col dp-list-add-to-cart dp-col_1_of_5">';
     if (in_array('price', $enable)) {
         $result .= '<div class="dp-list-price dp-price">' . $product->get_price_html() . '</div>';
     }
     $result .= '<div class="dp-stock"></div>';
     if (in_array('button', $enable)) {
         switch ($dp_addtocartbutton['type']) {
             case 'buttonquantity':
                 ob_start();
                 woocommerce_template_single_add_to_cart();
                 $result .= ob_get_contents();
                 ob_end_clean();
                 break;
             case 'productDetail':
                 $result .= '<div class="dp-grid-button">' . dp_add_to_cart_productdetail(get_permalink(), $addtocarttext) . '</div>';
                 break;
             case 'customButton':
                 $result .= '<div class="dp-grid-button">' . dp_add_to_cart_customButton($addtocarturl, $addtocarttext) . '</div>';
                 break;
             case 'customText':
                 $result .= '<div class="dp-grid-button">' . dp_add_to_cart_customText($addtocarturl, $addtocarttext) . '</div>';
                 break;
             default:
                 $result .= '<div class="dp-grid-button">' . dp_add_to_cart() . '</div>';
                 break;
开发者ID:k2jysy,项目名称:mergeshop,代码行数:31,代码来源:list.php


示例5: kt_woocommerce_single_product

    function kt_woocommerce_single_product()
    {
        ?>
        <div class="product-detail-info">
            <div class="product-section">
                <?php 
        woocommerce_template_single_meta();
        woocommerce_template_single_rating();
        woocommerce_template_single_excerpt();
        ?>
            </div>
            <div class="product-section">
                <?php 
        woocommerce_template_single_add_to_cart();
        ?>
                <div class="group-product-price">
                    <label><?php 
        esc_html_e('Price', 'kutetheme');
        ?>
</label>
                    <?php 
        woocommerce_template_single_price();
        ?>
                </div>
            </div>
            <div class="product-section">
                <?php 
        woocommerce_template_single_sharing();
        ?>
            </div>
        </div>
        <?php 
    }
开发者ID:hikaram,项目名称:wee,代码行数:33,代码来源:woocommerce.php


示例6: wpv_woo_buy_options_func

 public function wpv_woo_buy_options_func($atts)
 {
     global $post, $wpdb, $woocommerce;
     if ('product' == $post->post_type) {
         //Run only on single product page
         if (is_product()) {
             $product = $this->wcviews_setup_product_data($post);
             if (isset($atts['add_to_cart_text'])) {
                 if (!empty($atts['add_to_cart_text'])) {
                     //User is setting add to cart text customized
                     $add_to_cart_text_product_page = trim($atts['add_to_cart_text']);
                     //START support for string translation
                     if (function_exists('icl_register_string')) {
                         //Register add to cart text product listing for translation
                         icl_register_string('woocommerce_views', 'product_add_to_cart_text', $add_to_cart_text_product_page);
                     }
                     global $add_to_cart_text_product_page_translated;
                     if (!function_exists('icl_t')) {
                         //String translation plugin not available use original text
                         $add_to_cart_text_product_page_translated = $add_to_cart_text_product_page;
                     } else {
                         //String translation plugin available return translation
                         $add_to_cart_text_product_page_translated = icl_t('woocommerce_views', 'product_add_to_cart_text', $add_to_cart_text_product_page);
                     }
                     $using_revised_woocommerce = $this->wcviews_using_woocommerce_two_point_one_above();
                     if ($using_revised_woocommerce) {
                         add_filter('woocommerce_product_single_add_to_cart_text', array(&$this, 'single_add_to_cart_text_closure_func'));
                     } else {
                         add_filter('single_add_to_cart_text', array(&$this, 'single_add_to_cart_text_closure_func'));
                     }
                 }
             }
             ob_start();
             if ('simple' == $product->product_type) {
                 do_action('woocommerce_simple_add_to_cart');
             } elseif ('variable' == $product->product_type) {
                 do_action('woocommerce_variable_add_to_cart');
             } elseif ('grouped' == $product->product_type) {
                 do_action('woocommerce_grouped_add_to_cart');
             } elseif ('external' == $product->product_type) {
                 do_action('woocommerce_external_add_to_cart');
             } else {
                 /** https://icanlocalize.basecamphq.com/projects/11629195-toolset-peripheral-work/todo_items/195444907/comments */
                 /** Let's handle any peculiar WooCommerce product post types not covered above */
                 /** First let's double check if $product->product_type exists */
                 if (isset($product->product_type)) {
                     //product_type is set
                     $product_type_passed = $product->product_type;
                     if (!empty($product_type_passed)) {
                         //Has sensible value, let's call 'woocommerce_template_single_add_to_cart' core function to display add to cart
                         if (function_exists('woocommerce_template_single_add_to_cart')) {
                             //Function exist, call!
                             woocommerce_template_single_add_to_cart();
                         }
                     }
                 }
             }
             return ob_get_clean();
         }
     }
 }
开发者ID:rebeccayshen,项目名称:kitlist,代码行数:61,代码来源:Class_WooCommerce_Views.php


示例7: get_featured_product

        public function get_featured_product()
        {
            // Do not proceed if is_shop() function from WooCommerce core is not found.
            if (!function_exists('is_shop')) {
                return;
            }
            global $wp_query, $woocommerce_loop;
            if (!is_tax('product_cat')) {
                return;
            }
            $queried_object = (array) $wp_query->queried_object;
            // setup query
            $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => 1, 'tax_query' => array(array('taxonomy' => 'product_cat', 'field' => 'id', 'terms' => $queried_object['term_taxonomy_id'])), 'meta_query' => array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN'), array('key' => '_featured', 'value' => 'yes')));
            $products = new WP_Query($args);
            if ($products->have_posts()) {
                while ($products->have_posts()) {
                    $products->the_post();
                    $product = get_product($products->post->ID);
                    $product_id = get_the_ID();
                    if (isset($archive_query)) {
                        if (in_array($product_id, $query_products)) {
                            $product = isset($product) ? $product : false;
                        }
                    } elseif (is_shop()) {
                        $product = isset($product) ? $product : false;
                    }
                    if ($product) {
                        ?>
					<div class="featured-product-wrapper product">
						<div class="row">
							<?php 
                        if (has_post_thumbnail($product->id)) {
                            ?>
								<div class="col_4">
									<a href="<?php 
                            the_permalink();
                            ?>
"><?php 
                            echo get_the_post_thumbnail($product->id, 'full');
                            ?>
</a>
								</div>
								<div class="col_8">
									<a href="<?php 
                            the_permalink();
                            ?>
"><h2><?php 
                            echo $product->post->post_title;
                            ?>
</h2></a>
									<p><?php 
                            echo $product->post->post_excerpt;
                            ?>
</p>
									<?php 
                            woocommerce_template_single_add_to_cart();
                            ?>
								</div>
							<?php 
                        }
                        ?>
						</div>
					</div>
					<div class="clear" style="padding-top: 1em;"></div>
				<?php 
                    }
                }
            }
            wp_reset_query();
        }
开发者ID:Wordpress-Development,项目名称:ornea,代码行数:70,代码来源:class-ornea-wc.php


示例8: custom_woocommerce_template_single_add_to_cart

function custom_woocommerce_template_single_add_to_cart()
{
    global $product;
    if ($product->get_type() == 'variable') {
        $filhas = $product->get_children();
        $estoque = 0;
        foreach ($filhas as $filha => $id) {
            $produto = get_product($id);
            if ($produto->get_stock_quantity() != 0) {
                $estoque = 1;
            }
            // 	echo '<prev>';
            // print_r($produto->get_stock_quantity());
            // echo '</prev>';
        }
        if ($estoque == 0) {
            $link = $product->get_permalink();
            $prices = $product->get_variation_prices(true);
            $min_price = current($prices['regular_price']);
            echo '';
            echo '<div class="preco" style="display:block;float:left;width:initial" itemprop="offers" itemscope="" itemtype="http://schema.org/Offer">
				<p class="price"> <ins><span class="amount">R$' . $min_price . '</span></ins></p>
				<meta itemprop="price" content="10">
				<meta itemprop="priceCurrency" content="BRL">
				<link itemprop="availability" href="http://schema.org/OutOfStock">
				
				</div>
				<div class="botao-comprar">
				Esgotado!<br><a data-link="' . $link . '" data-nome="' . $product->get_title() . '"class="encomendarAdd button" href="#" class="button addtocartbutton">Encomendar</a>
				</div>';
        } else {
            woocommerce_template_single_add_to_cart();
        }
    } else {
        woocommerce_template_single_add_to_cart();
    }
}
开发者ID:willowmagrini,项目名称:dg,代码行数:37,代码来源:functions.php


示例9: ocin_lite_single_product_wrap_end_summary

/**
 * HTML wrap end for Single page summary
 */
function ocin_lite_single_product_wrap_end_summary()
{
    ?>
		<div class="variations_button_entry">
            <?php 
    woocommerce_template_single_add_to_cart();
    ?>
        </div>
	</div><!-- /entry -->
	<div class="summary-bottom">
        <div class="woocommerce-variation-add-to-cart variations_button">
			<div class="quantity">
				<input type="number" size="4" class="input-text qty text" title="Qty" value="1" name="quantity" min="1" step="1">
			</div>
			<button class="single_add_to_cart_button button alt" type="submit"><?php 
    esc_html_e('Add to cart', 'ocin-lite');
    ?>
</button>
		</div>

        <div class="social-share">
        	<?php 
    if (function_exists('sharing_display')) {
        sharing_display('', true);
    }
    ?>
        </div>
    </div>
	<?php 
}
开发者ID:nicoandrade,项目名称:Ocin-Lite,代码行数:33,代码来源:woocommerce_support.php


示例10: add_cart_button_template

 function add_cart_button_template()
 {
     woocommerce_template_single_add_to_cart();
 }
开发者ID:linniepinski,项目名称:perssistant,代码行数:4,代码来源:ce_shop.php


示例11: product_quickview

function product_quickview()
{
    global $product, $post, $woocommerce_loop, $road_opt;
    if ($_POST['data']) {
        $productid = intval($_POST['data']);
        $product = get_product($productid);
        $post = get_post($productid);
    }
    ?>
	<div class="woocommerce product">
		<div class="product-images">
			<?php 
    $image_link = wp_get_attachment_url($product->get_image_id());
    ?>
			<div class="main-image images"><img src="<?php 
    echo esc_attr($image_link);
    ?>
" alt="" /></div>
			<?php 
    $attachment_ids = $product->get_gallery_attachment_ids();
    if ($attachment_ids) {
        ?>
				<div class="quick-thumbnails">
					<?php 
        $image_link = wp_get_attachment_url($product->get_image_id());
        ?>
					<div><a href="<?php 
        echo esc_attr($image_link);
        ?>
"><?php 
        echo $product->get_image('shop_thumbnail');
        ?>
</a></div>
					<?php 
        $loop = 0;
        $columns = apply_filters('woocommerce_product_thumbnails_columns', 3);
        foreach ($attachment_ids as $attachment_id) {
            ?>
						<div>
						<?php 
            $classes = array('zoom');
            if ($loop == 0 || $loop % $columns == 0) {
                $classes[] = 'first';
            }
            if (($loop + 1) % $columns == 0) {
                $classes[] = 'last';
            }
            $image_link = wp_get_attachment_url($attachment_id);
            if (!$image_link) {
                continue;
            }
            $image = wp_get_attachment_image($attachment_id, apply_filters('single_product_small_thumbnail_size', 'shop_thumbnail'));
            $image_class = esc_attr(implode(' ', $classes));
            $image_title = esc_attr(get_the_title($attachment_id));
            echo apply_filters('woocommerce_single_product_image_thumbnail_html', sprintf('<a href="%s" class="%s" title="%s" data-rel="prettyPhoto[product-gallery]">%s</a>', $image_link, $image_class, $image_title, $image), $attachment_id, $product->ID, $image_class);
            $loop++;
            ?>
						</div>
						<?php 
        }
        ?>
				</div>
				<?php 
    }
    ?>
		</div>
		<div class="product-info">
			<h1><?php 
    echo esc_html($product->get_title());
    ?>
</h1>
			
			<div class="price-box" itemprop="offers" itemscope itemtype="http://schema.org/Offer">
				<p class="price"><?php 
    echo $product->get_price_html();
    ?>
</p>
			</div>
			
			<a class="see-all" href="<?php 
    echo esc_url($product->get_permalink());
    ?>
"><?php 
    echo esc_html($road_opt['quickview_link_text']);
    ?>
</a>
			<div class="quick-add-to-cart">
				<?php 
    woocommerce_template_single_add_to_cart();
    ?>
			</div>
			<div class="quick-desc"><?php 
    echo do_shortcode(get_post($productid)->post_excerpt);
    ?>
</div>
			<div class="social-sharing"><?php 
    road_product_sharing();
    ?>
</div>
		</div>
//.........这里部分代码省略.........
开发者ID:andersonaguiaralves,项目名称:meiotomloja,代码行数:101,代码来源:wooajax.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP woocommerce_template_single_excerpt函数代码示例发布时间:2022-05-23
下一篇:
PHP woocommerce_template_loop_price函数代码示例发布时间: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