本文整理汇总了PHP中WC_Product_Variation::add_to_cart_url方法的典型用法代码示例。如果您正苦于以下问题:PHP WC_Product_Variation::add_to_cart_url方法的具体用法?PHP WC_Product_Variation::add_to_cart_url怎么用?PHP WC_Product_Variation::add_to_cart_url使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WC_Product_Variation
的用法示例。
在下文中一共展示了WC_Product_Variation::add_to_cart_url方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
function add_sponsorship_project_to_cart()
{
global $post;
$args = array('post_type' => 'product_variation', 'post_status' => array('private', 'publish'), 'numberposts' => -1, 'orderby' => 'id', 'order' => 'asc', 'post_parent' => $post->ID);
$levels = get_posts($args);
do_action('woocommerce_before_add_to_cart_button');
?>
<div class="sp-levels">
<?php
foreach ($levels as $level) {
$level_product = new WC_Product_Variation($level->ID);
$level_data = get_post_custom($level->ID);
?>
<form id="level-<?php
echo $level->ID;
?>
-form" enctype="multipart/form-data" method="post" class="cart" action="<?php
echo $level_product->add_to_cart_url();
?>
">
<a class="sp-level" rel="<?php
echo $level->ID;
?>
">
<div class="sp-level-title">
<?php
echo get_the_title($level->ID);
?>
<div class="sp-level-amount">
<strong>$<?php
echo isset($level_data['_price'][0]) ? $level_data['_price'][0] : 0;
?>
</strong>
</div>
</div>
<div class="sp-level-description">
<?php
echo $level->post_content;
?>
</div>
</a>
</form>
<?php
}
?>
</div>
<script>
jQuery('.sp-level').click(function() {
var levelId = jQuery(this).attr('rel');
jQuery('#level-' + levelId + '-form').submit();
return false;
})
</script>
<?php
do_action('woocommerce_after_add_to_cart_button');
}
示例2: isset
?>
</div>
<span class="sp-project-duration-label text">days to go</span>
</h5>
</div>
</div>
<?php
if (isset($min_level)) {
?>
<div class="sp-project-contribute">
<div>
<form id="level-<?php
echo $min_level_id;
?>
-form" enctype="multipart/form-data" method="post" class="cart" action="<?php
echo $min_level->add_to_cart_url();
?>
">
<a id="sp-project-min-pledge-button" rel="<?php
echo $min_level_id;
?>
">
Back This Project
<small>$<?php
echo isset($min_level_data['_price'][0]) ? $min_level_data['_price'][0] : 0;
?>
minimum pledge</small>
</a>
</form>
</div>
</div>
开发者ID:orlandomario,项目名称:WooSponsorship,代码行数:31,代码来源:class-wc-sponsorship-project-status-template.php