本文整理汇总了PHP中woocommerce_template_loop_add_to_cart函数的典型用法代码示例。如果您正苦于以下问题:PHP woocommerce_template_loop_add_to_cart函数的具体用法?PHP woocommerce_template_loop_add_to_cart怎么用?PHP woocommerce_template_loop_add_to_cart使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了woocommerce_template_loop_add_to_cart函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: zn_add_to_cart
function zn_add_to_cart()
{
ob_start();
woocommerce_template_loop_add_to_cart();
$output = ob_get_clean();
echo '<div class="zn_add_to_cart">' . $output . '</div>';
}
示例2: dokan_product_loop_price
/**
* Renders item-bar of products in the loop
*
* @global WC_Product $product
*/
function dokan_product_loop_price()
{
global $product;
?>
<span class="item-bar">
<?php
woocommerce_template_loop_price();
?>
<span class="item-button">
<?php
woocommerce_template_loop_add_to_cart();
?>
<?php
if (function_exists('dokan_add_to_wishlist_link')) {
dokan_add_to_wishlist_link();
}
?>
</span>
</span>
<?php
}
示例3: vntd_woocommerce_loop_thumbnail
function vntd_woocommerce_loop_thumbnail()
{
echo '<div class="product-thumbnail-wrap">';
woocommerce_template_loop_product_thumbnail();
echo '<div class="product-overlay-add">';
woocommerce_template_loop_add_to_cart();
echo '</div></div>';
}
示例4: waxom_woocommerce_loop_thumbnail
function waxom_woocommerce_loop_thumbnail()
{
echo '<div class="product-thumbnail-wrap vntd-accent-bg-color">';
woocommerce_template_loop_product_thumbnail();
echo '<div class="product-overlay">';
echo '<div class="product-overlay-inner">';
woocommerce_template_loop_add_to_cart();
echo '</div></div></div>';
echo '<div class="product-details-wrap"><div class="product-category">' . waxom_product_categories() . '</div>';
}
示例5: get_the_post_thumbnail
<?php
if (has_post_thumbnail($loop->post->ID)) {
echo get_the_post_thumbnail($loop->post->ID, 'shop_catalog');
} else {
echo '<img src="' . woocommerce_placeholder_img_src() . '" alt="Placeholder" width="300px" height="300px" />';
}
?>
<h3><?php
the_title();
?>
</h3>
<span class="price"><?php
echo $product->get_price_html();
?>
</span>
</a>
<?php
woocommerce_template_loop_add_to_cart($loop->post, $product);
?>
</li>
<?php
}
wp_reset_query();
示例6: avia_add_cart_button
function avia_add_cart_button()
{
global $product, $avia_config;
if ($product->product_type == 'bundle') {
$product = new WC_Product_Bundle($product->id);
}
$extraClass = "";
ob_start();
woocommerce_template_loop_add_to_cart();
$output = ob_get_clean();
if (!empty($output)) {
$pos = strpos($output, ">");
if ($pos !== false) {
$output = substr_replace($output, "><span " . av_icon_string('cart') . "></span> ", $pos, strlen(1));
}
}
if ($product->product_type == 'variable' && empty($output)) {
$output = '<a class="add_to_cart_button button product_type_variable" href="' . get_permalink($product->id) . '"><span ' . av_icon_string("details") . '></span> ' . __("Select options", "avia_framework") . '</a>';
}
if ($product->product_type == 'simple' || $product->product_type == 'subscription') {
$output .= '<a class="button show_details_button" href="' . get_permalink($product->id) . '"><span ' . av_icon_string("details") . '></span> ' . __("Show Details", "avia_framework") . '</a>';
} else {
$extraClass = "single_button";
}
if (empty($extraClass)) {
$output .= " <span class='button-mini-delimiter'></span>";
}
if ($output && !post_password_required()) {
echo "<div class='avia_cart_buttons {$extraClass}'>{$output}</div>";
}
}
示例7: rd_add_cart_button
function rd_add_cart_button()
{
global $product, $rd_config;
if ($product->product_type == 'bundle') {
$product = new WC_Product_Bundle($product->id);
}
$extraClass = "";
ob_start();
woocommerce_template_loop_add_to_cart();
$output = ob_get_clean();
if (!empty($output)) {
$pos = strpos($output, ">");
if ($pos !== false) {
$output = substr_replace($output, "> ", $pos, strlen(1));
}
}
if ($product->product_type == 'variable' && empty($output)) {
$output = '<a class="add_to_cart_button button product_type_variable" href="' . get_permalink($product->id) . '"> ' . __("Select options", "rd_framework") . '</a>';
}
if (in_array($product->product_type, array('subscription', 'simple', 'bundle'))) {
$output .= '<a class="button show_details_button" href="' . get_permalink($product->id) . '"> ' . __("Show Details", "rd_framework") . '</a>';
}
if (!$product->is_in_stock()) {
$output = '<a href="' . get_permalink() . '" rel="nofollow" class="button add_to_cart_button more_info_button out_stock_button"> ' . __("Out of Stock", "rd_framework") . '</a>';
} else {
$extraClass = "single_button";
}
if (empty($extraClass)) {
$output .= " <span class='button-mini-delimiter'></span>";
}
if ($output && !post_password_required()) {
echo "<div class='custom_cart_button {$extraClass}'>{$output}</div>";
}
}
示例8: dt_woocommerce_shop_overview_extra_div_close
function dt_woocommerce_shop_overview_extra_div_close()
{
global $product;
$link = apply_filters('out_of_stock_add_to_cart_url', get_permalink($product->id));
$out = "";
ob_start();
woocommerce_template_loop_price();
$price = ob_get_clean();
ob_start();
woocommerce_template_loop_add_to_cart();
$add_to_cart = ob_get_clean();
if (!empty($add_to_cart)) {
$add_to_cart = str_replace(' class="', ' class="dt-sc-button ', $add_to_cart);
}
$out .= '<!-- Product Details -->';
$out .= "<div class='product-details'>";
$out .= $price;
$out .= $add_to_cart;
$out .= '</div><!-- Product Details -->';
$out .= '<div class="product-details-hover">';
$out .= "<h3><a href='{$link}'>" . $product->get_title() . '</a></h3>';
$rating = $product->get_rating_html();
//get rating
$rating = !empty($rating) ? $rating : "";
$out .= $rating;
$out .= $price;
$out .= $add_to_cart;
if (shortcode_exists('yith_wcwl_add_to_wishlist')) {
$out .= do_shortcode('[yith_wcwl_add_to_wishlist]');
}
$out .= '</div><!-- Product Details Hover -->';
$out .= "</div> </div> <!-- Product Wrapper End-->";
echo $out;
}
示例9: the_title
" title="<?php
the_title();
?>
"><h3><?php
the_title();
?>
</h3></a>
</div>
</div>
<div class="product-price-cart">
<div class="recentPrice"><span class="price"><?php
echo $product->get_price_html();
?>
</span></div>
<div class="recentCart"><?php
woocommerce_template_loop_add_to_cart($product);
?>
</div>
</div>
</div>
<?php
$count++;
if ($countitem == 4) {
$countitem = 0;
?>
</li>
<?php
}
$countitem++;
$countPost++;
示例10: woo_loop_product_thumbnail
/**
*
* Product thumbnail for loop
*/
function woo_loop_product_thumbnail()
{
if (has_post_thumbnail()) {
echo '<figure class="featured-image img-preload img-hover">';
echo '<a href="' . get_permalink() . '">';
the_post_thumbnail('shop_catalog');
echo '<div class="overlay"></div>';
echo '</a>';
woocommerce_template_loop_add_to_cart();
woocommerce_show_product_loop_sale_flash();
echo '</figure>';
}
}
示例11: tpvc_wc_product_featured_shortcode
//.........这里部分代码省略.........
?>
>
<div class="featured-top">
<?php
the_post_thumbnail('custom-woo-thumbnail');
?>
</div>
<?php
if ("yes" != $tpvc_wc_featured_hide_prodprice || "yes" != $tpvc_wc_featured_hide_prodtitle || "yes" != $tpvc_wc_featured_hide_prodlink || "yes" != $tpvc_wc_featured_hide_prodcart) {
?>
<div class="featured-bottom">
<?php
if ("yes" != $tpvc_wc_featured_hide_prodprice) {
?>
<div class="featured-price">
<?php
woocommerce_template_loop_price();
?>
</div>
<?php
}
?>
<?php
if ("yes" != $tpvc_wc_featured_hide_prodlink || "yes" != $tpvc_wc_featured_hide_prodcart) {
?>
<div class="featured-action">
<?php
if ("yes" != $tpvc_wc_featured_hide_prodlink) {
?>
<a href="<?php
echo get_permalink();
?>
" class="button detail_button_loop">
<?php
if (!$tpvc_wc_featured_hide_prodlink_text) {
$tpvc_wc_featured_hide_prodlink_text = __('detail', 'tokopress');
}
echo $tpvc_wc_featured_hide_prodlink_text;
?>
</a>
<?php
}
?>
<?php
if ("yes" != $tpvc_wc_featured_hide_prodcart) {
?>
<?php
woocommerce_template_loop_add_to_cart();
?>
<?php
}
?>
</div>
<?php
}
?>
<?php
if ("yes" != $tpvc_wc_featured_hide_prodtitle) {
?>
<div class="featured-title">
<h3><a href="<?php
echo get_permalink();
?>
"><?php
the_title();
?>
</a></h3>
</div>
<?php
}
?>
</div>
<?php
}
?>
</li>
<?php
}
?>
</ul>
</div>
<?php
}
wp_reset_postdata();
$js_code = '$(\'.tpvc-featured-product ul.owl-carousel\').owlCarousel({
items : 1,
loop: true,
nav : true,
stopOnHover : true,
navText : [\'<i class="fa fa-chevron-left"></i>\', \'<i class="fa fa-chevron-right"></i>\'],
lazyLoad: true,
autoplay: true,
dots: false
});';
wc_enqueue_js($js_code);
return ob_get_clean();
}
示例12: product_add_to_cart
/**
* Display a single product price + cart button
*
* @access public
* @param array $atts
* @return string
*/
public function product_add_to_cart($atts)
{
global $wpdb, $post, $woocommerce;
if (empty($atts)) {
return;
}
if (!isset($atts['style'])) {
$atts['style'] = 'border:4px solid #ccc; padding: 12px;';
}
if (isset($atts['id'])) {
$product_data = get_post($atts['id']);
} elseif (isset($atts['sku'])) {
$product_id = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key='_sku' AND meta_value='%s' LIMIT 1", $atts['sku']));
$product_data = get_post($product_id);
} else {
return;
}
if ('product' == $product_data->post_type) {
$product = $woocommerce->setup_product_data($product_data);
ob_start();
?>
<p class="product woocommerce" style="<?php
echo $atts['style'];
?>
">
<?php
echo $product->get_price_html();
?>
<?php
woocommerce_template_loop_add_to_cart();
?>
</p><?php
// Restore Product global in case this is shown inside a product post
$woocommerce->setup_product_data($post);
return ob_get_clean();
} elseif ('product_variation' == $product_data->post_type) {
$product = get_product($product_data->post_parent);
$GLOBALS['product'] = $product;
$variation = get_product($product_data);
ob_start();
?>
<p class="product product-variation" style="<?php
echo $atts['style'];
?>
">
<?php
echo $product->get_price_html();
?>
<?php
$link = $product->add_to_cart_url();
$label = apply_filters('add_to_cart_text', __('Add to cart', 'woocommerce'));
$link = add_query_arg('variation_id', $variation->variation_id, $link);
foreach ($variation->variation_data as $key => $data) {
if ($data) {
$link = add_query_arg($key, $data, $link);
}
}
printf('<a href="%s" rel="nofollow" data-product_id="%s" class="button add_to_cart_button product_type_%s">%s</a>', esc_url($link), $product->id, $product->product_type, $label);
?>
</p><?php
wp_reset_postdata();
return ob_get_clean();
}
}
示例13: pmc_productBlock
//.........这里部分代码省略.........
}
?>
</div>
</div>
<?php
} else {
?>
<div class="recentimage">
<div class="image">
<div class="loading"></div>
<?php
if (has_post_thumbnail(get_the_ID())) {
echo '<img src = ' . $image . ' alt = "' . get_the_title() . '" > ';
} else {
echo '<img src="' . woocommerce_placeholder_img_src() . '" alt="Placeholder" width="230px" height="' . $pmc_data['catalog_img_height'] . 'px" />';
}
?>
</div>
</div>
<?php
if ($product_ajax != 'true') {
?>
</a>
<?php
}
?>
<?php
}
?>
<div class="recentdescription">
<?php
woocommerce_show_product_sale_flash($product);
?>
<?php
if ($product_ajax != 'true') {
?>
<a href="<?php
echo get_permalink(get_the_id());
?>
">
<?php
}
?>
<h3><?php
the_title();
?>
</h3>
<?php
if ($product_ajax != 'true') {
?>
</a>
<?php
}
?>
</div>
<?php
if ($product_ajax == 'true') {
?>
</div>
<?php
}
?>
<div class="product-price-cart">
<div class="recentPrice"><span class="price"><?php
echo $product->get_price_html();
?>
</span></div>
<div class="recentCart"><?php
woocommerce_template_loop_add_to_cart($product);
?>
</div>
</div>
</div>
<?php
$countPost++;
if ($countitem == $rows) {
$countitem = 0;
?>
</li>
<?php
}
$countitem++;
}
}
wp_reset_query();
?>
</ul>
</div>
</div>
</div>
</div>
<?php
}
示例14: widget
//.........这里部分代码省略.........
while ($loop->have_posts()) {
$loop->the_post();
global $product;
global $woocommerce;
$large_image_url = wp_get_attachment_image_src(get_post_thumbnail_id($loop->post->ID), apply_filters('single_product_large_thumbnail_size', 'shop_catalog'));
$productlink = get_permalink($loop->post->ID);
$content_excerpt = apply_filters('woocommerce_short_description', $loop->post->post_excerpt);
?>
<li class="product-grid-container">
<div class="product-item">
<div class="title">
<h3 class="title-container product-titles"><a href="<?php
echo $productlink;
?>
"><?php
the_title();
?>
</a></h3>
</div>
<div class="image mosaic-block bar">
<?php
if ($content_excerpt != "") {
?>
<a href="<?php
echo $productlink;
?>
" class="mosaic-overlay">
<div class="details">
<?php
echo $content_excerpt;
?>
</div>
</a><?php
}
?>
<a href="<?php
echo $productlink;
?>
">
<span class="price heading-style"><?php
echo $product->get_price_html();
?>
</span>
<?php
woocommerce_show_product_sale_flash($loop->post, $product);
?>
<?php
if (!$large_image_url == "") {
?>
<img src="<?php
echo $large_image_url[0];
?>
" alt="" /><?php
} else {
?>
<img src="<?php
echo woocommerce_placeholder_img_src();
?>
" width="240" height="160" alt="" /><?php
}
?>
</a>
</div>
<div class="info">
<div class="float-left">
<?php
woocommerce_template_loop_rating($loop->post, $product);
?>
</div>
<div class="float-right">
<?php
woocommerce_template_loop_add_to_cart($loop->post, $product);
?>
</div>
</div>
</div>
</li>
<?php
}
wp_reset_query();
?>
</ul>
<div id="pager<?php
echo $uni_carousel_id;
$uni_carousel_id++;
?>
" class="pager"></div>
<div class="clear"></div>
</div><?php
}
?>
</div>
<?php
}
示例15: content
//.........这里部分代码省略.........
<?php
if ($enable_countdown == 'on' && $y > 1970) {
?>
<?php
if ($countdown_text) {
?>
<h3 class="title"><?php
echo esc_html($countdown_text);
?>
</h3>
<?php
}
?>
<span class="countdown-lastest" data-y="<?php
_e(esc_attr($y));
?>
" data-m="<?php
_e(esc_attr($m));
?>
" data-d="<?php
_e(esc_attr($d));
?>
" data-h="<?php
_e(esc_attr($h));
?>
" data-i="<?php
_e(esc_attr($mi));
?>
" data-s="<?php
_e(esc_attr($s));
?>
"></span>
<?php
}
?>
<?php
$meta_query = WC()->query->get_meta_query();
$ids = explode(',', $product_id);
$args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => 1, 'meta_query' => $meta_query, 'suppress_filter' => true);
if (is_array($ids) && !empty($ids)) {
$args['post__in'] = $ids;
$args['orderby'] = 'post__in';
}
$products = new WP_Query(apply_filters('woocommerce_shortcode_products_query', $args, $atts));
if ($products->have_posts()) {
remove_action('kt_after_shop_loop_item_title', 'woocommerce_template_loop_rating');
while ($products->have_posts()) {
$products->the_post();
?>
<div class="product-info">
<h4 class="product-name"><a href="<?php
the_permalink();
?>
" title="<?php
the_title();
?>
"></a><?php
the_title();
?>
</h4>
<div class="desc"><?php
the_excerpt();
?>
</div>
<?php
/**
* woocommerce_after_shop_loop_item_title hook
*
* @hooked woocommerce_template_loop_price - 5
* @hooked woocommerce_template_loop_rating - 10
*/
do_action('kt_after_shop_loop_item_title');
?>
<div class="group-button-control">
<?php
woocommerce_template_loop_add_to_cart();
?>
<?php
kt_get_tool_wishlish();
?>
</div>
</div>
<?php
}
// end of the loop.
wp_reset_query();
wp_reset_postdata();
add_action('kt_after_shop_loop_item_title', 'woocommerce_template_loop_rating');
}
?>
</div>
</div>
</div>
</div>
</div>
<?php
}
return ob_get_clean();
}