本文整理汇总了PHP中wpsc_product_has_stock函数的典型用法代码示例。如果您正苦于以下问题:PHP wpsc_product_has_stock函数的具体用法?PHP wpsc_product_has_stock怎么用?PHP wpsc_product_has_stock使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wpsc_product_has_stock函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1:
<?php
if (wpsc_product_is_customisable()) {
?>
<input type="hidden" value="true" name="is_customisable"/>
<?php
}
?>
<!-- END OF QUANTITY OPTION -->
<?php
if (get_option('hide_addtocart_button') == 0 && get_option('addtocart_or_buynow') != '1') {
?>
<?php
if (wpsc_product_has_stock()) {
?>
<?php
if (wpsc_product_external_link(wpsc_the_product_id()) != '') {
?>
<?php
$action = wpsc_product_external_link(wpsc_the_product_id());
?>
<input class="wpsc_buy_button" type='button' value='<?php
echo __('Buy Now', 'wpsc');
?>
' onclick='gotoexternallink("<?php
echo $action;
?>
")'>
<?php
开发者ID:Jonathonbyrd,项目名称:wp-ecommerce,代码行数:31,代码来源:single_product.php
示例2: wpsc_product_has_stock
/**
* wpsc product has stock function
* @return boolean - true if the product has stock or does not use stock, false if it does not
*/
function wpsc_product_has_stock($id = null)
{
// maybe do wpsc_clear_stock_claims first?
if (is_numeric($id) && $id > 0) {
$id = absint($id);
} else {
$id = get_the_ID();
}
$stock = get_post_meta($id, '_wpsc_stock', true);
if ($stock === '') {
return true;
}
$variations = get_children(array("post_type" => "wpsc-product", "post_parent" => $id));
$filter_name = empty($variations) ? 'wpsc_product_stock' : 'wpsc_product_variation_stock';
$stock = apply_filters($filter_name, (int) $stock, $id);
if (!empty($variations)) {
foreach ($variations as $variation) {
if (wpsc_product_has_stock($variation->ID)) {
return true;
}
}
} elseif ($stock > 0) {
$claimed_query = new WPSC_Claimed_Stock(array('product_id' => $id));
$claimed_stock = $claimed_query->get_claimed_stock_count();
if ($stock - $claimed_stock > 0) {
return true;
}
}
return false;
}
开发者ID:AngryBird3,项目名称:WP-e-Commerce,代码行数:34,代码来源:template-tags.php
示例3: wpsc_generate_product_feed
//.........这里部分代码省略.........
$products = get_posts($args);
while (count($products)) {
foreach ($products as $post) {
setup_postdata($post);
$purchase_link = wpsc_product_url($post->ID);
echo " <item>\n\r";
if ($google_checkout_note) {
echo " <g:payment_notes>Google Checkout</g:payment_notes>\n\r";
}
echo " <title><![CDATA[" . get_the_title() . "]]></title>\n\r";
echo " <link>{$purchase_link}</link>\n\r";
echo " <description><![CDATA[" . apply_filters('the_content', get_the_content()) . "]]></description>\n\r";
echo " <pubDate>" . $post->post_modified_gmt . "</pubDate>\n\r";
echo " <guid>{$purchase_link}</guid>\n\r";
$image_link = wpsc_the_product_thumbnail();
if ($image_link !== FALSE) {
if ($_GET['xmlformat'] == 'google') {
echo " <g:image_link>{$image_link}</g:image_link>\n\r";
} else {
echo " <enclosure url='{$image_link}' />\n\r";
}
}
$price = wpsc_calculate_price($post->ID);
$currargs = array('display_currency_symbol' => false, 'display_decimal_point' => true, 'display_currency_code' => false, 'display_as_html' => false);
$price = wpsc_currency_display($price, $currargs);
$children = get_children(array('post_parent' => $post->ID, 'post_type' => 'wpsc-product'));
foreach ($children as $child) {
$child_price = wpsc_calculate_price($child->ID);
if ($price == 0 && $child_price > 0) {
$price = $child_price;
} else {
if ($child_price > 0 && $child_price < $price) {
$price = $child_price;
}
}
}
if ($_GET['xmlformat'] == 'google') {
echo " <g:price>" . $price . "</g:price>\n\r";
$google_elements = array();
$product_meta = get_post_custom($post->ID);
if (is_array($product_meta)) {
foreach ($product_meta as $meta_key => $meta_value) {
if (stripos($meta_key, 'g:') === 0) {
$google_elements[$meta_key] = $meta_value;
}
}
}
$google_elements = apply_filters('wpsc_google_elements', array('product_id' => $post->ID, 'elements' => $google_elements));
$google_elements = $google_elements['elements'];
$done_condition = FALSE;
$done_availability = FALSE;
$done_weight = FALSE;
if (count($google_elements)) {
foreach ($google_elements as $element_name => $element_values) {
foreach ($element_values as $element_value) {
echo " <" . $element_name . ">";
echo "<![CDATA[" . $element_value . "]]>";
echo "</" . $element_name . ">\n\r";
}
if ($element_name == 'g:shipping_weight') {
$done_weight = TRUE;
}
if ($element_name == 'g:condition') {
$done_condition = TRUE;
}
if ($element_name == 'g:availability') {
$done_availability = true;
}
}
}
if (!$done_condition) {
echo " <g:condition>new</g:condition>\n\r";
}
if (!$done_availability) {
if (wpsc_product_has_stock()) {
$product_availability = "in stock";
} else {
$product_availability = "out of stock";
}
echo " <g:availability>{$product_availability}</g:availability>";
}
if (!$done_weight) {
$wpsc_product_meta = get_product_meta($post->ID, 'product_metadata', true);
$weight = apply_filters('wpsc_google_shipping_weight', $wpsc_product_meta['weight'], $post->ID);
if ($weight && is_numeric($weight) && $weight > 0) {
echo "<g:shipping_weight>{$weight} pounds</g:shipping_weight>";
}
}
} else {
echo " <product:price>" . $price . "</product:price>\n\r";
}
echo " </item>\n\r";
}
$args['offset'] += $chunk_size;
$products = get_posts($args);
}
echo " </channel>\n\r";
echo "</rss>";
exit;
}
开发者ID:arturo-mayorga,项目名称:am_com,代码行数:101,代码来源:productfeed.php
示例4: ob_start
/**
* Renders the WPEC tickets table/form
*
* @version 4.2
*
* @var bool $must_login
*/
ob_start();
$is_there_any_product = false;
$is_there_any_product_to_sell = false;
foreach ($tickets as $ticket) {
if ($ticket->date_in_range(current_time('timestamp'))) {
$is_there_any_product = true;
echo '<tr>';
echo "<td width='115' class='wpec quantity' data-product-id='" . esc_attr($ticket->ID) . "'>";
if (wpsc_product_has_stock($ticket->ID)) {
$is_there_any_product_to_sell = true;
if (get_option('addtocart_or_buynow') == '1') {
echo wpsc_buy_now_button($ticket->ID);
} else {
?>
<fieldset>
<legend><?php
esc_html_e('Quantity', 'event-tickets-plus');
?>
</legend>
<div class="wpsc_quantity_update">
<input type="number" id="wpec_tickets_quantity_<?php
echo esc_attr($ticket->ID);
?>
" name="wpec_tickets_quantity[]" size="2" value="0" min="0" <?php
开发者ID:TakenCdosG,项目名称:chefs,代码行数:31,代码来源:tickets.php
示例5: send_product
public function send_product()
{
if (wpsc_is_single_product()) {
$product = array();
while (wpsc_have_products()) {
wpsc_the_product();
$product_id = (int) wpsc_the_product_id();
$product['url'] = (string) wpsc_the_product_permalink();
$product['product_id'] = $product_id;
$product['name'] = (string) wpsc_the_product_title();
$product['image_url'] = (string) wpsc_the_product_image('', '', $product_id);
if (wpsc_product_has_variations($product_id)) {
$price = $this->get_lowest_product_variation_price($product_id);
} else {
$price = wpsc_calculate_price($product_id, false, true);
}
$product['price'] = $this->format_price($price);
if (wpsc_product_has_stock($product_id)) {
$product['stock'] = 1;
} else {
$product['stock'] = 0;
}
$product['categories'] = array();
$category_terms = wp_get_product_categories($product_id);
foreach ($category_terms as $category_term) {
$category_path = $category_term;
if (!empty($category_path)) {
$product['category_name'] = $category_term->name;
$product['category_id'] = $category_term->term_id;
}
}
if (wpsc_product_has_variations($product_id)) {
$list_price = $this->get_lowest_product_variation_price($product_id);
} else {
$list_price = wpsc_calculate_price($product_id, false, false);
}
$product['list_price'] = $this->format_price($list_price);
}
if (!empty($product)) {
$this->render('sendProduct', array('product' => $product));
}
}
}
开发者ID:retargeting,项目名称:WP-eCommerce,代码行数:43,代码来源:wpec-retargeting.php
示例6: if
<?php if(wpsc_has_multi_adding()): ?>
<label class='wpsc_quantity_update' for='wpsc_quantity_update[<?php echo wpsc_the_product_id(); ?>]'><?php echo __('Quantity', 'wpsc'); ?>:</label>
+ <input type="text" id='wpsc_quantity_update[<?php echo wpsc_the_product_id(); ?>]' name="wpsc_quantity_update" size="2" value="1"/>
<input type="hidden" name="key" value="<?php echo wpsc_the_cart_item_key(); ?>"/>
<input type="hidden" name="wpsc_update_quantity" value="true"/>
<?php endif ;?>
<input type="hidden" value="add_to_cart" name="wpsc_ajax_action"/>
<input type="hidden" value="<?php echo wpsc_the_product_id(); ?>" name="product_id"/>
<?php if((get_option('hide_addtocart_button') == 0) && (get_option('addtocart_or_buynow') !='1')) : ?>
<?php if(wpsc_product_has_stock()) : ?>
<div class='wpsc_buy_button_container'>
<?php if(wpsc_product_external_link(wpsc_the_product_id()) != '') : ?>
<?php $action = wpsc_product_external_link(wpsc_the_product_id()); ?>
<input class="wpsc_buy_button" type='button' value='<?php echo __('Buy Now', 'wpsc'); ?>' onclick='gotoexternallink("<?php echo $action; ?>")'>
<?php else: ?>
<input type='image' src='<?php echo WPSC_URL; ?>/themes/iShop/images/buy_button.gif' id='product_<?php echo wpsc_the_product_id(); ?>_submit_button' class='wpsc_buy_button' name='Buy' value="<?php echo __('Add To Cart', 'wpsc'); ?>" />
<?php endif; ?>
<div class='wpsc_loading_animation'>
<img title="Loading" alt="Loading" src="<?php echo WPSC_URL; ?>/images/indicator.gif" class="loadingimage"/>
<?php echo __('Updating cart...', 'wpsc'); ?>
</div>
开发者ID:nerdfiles,项目名称:sideshowtramps.com,代码行数:28,代码来源:list_view.php
示例7: wpsc_is_product_out_of_stock
/**
* Determine whether a product is out of stock or not.
*
* @since 0.1
*
* @param null|int $id Optional. The product ID. Defaults to the current product in the loop.
* @return bool
*/
function wpsc_is_product_out_of_stock($id = null)
{
return !wpsc_product_has_stock($id);
}
开发者ID:osuarcher,项目名称:WP-e-Commerce,代码行数:12,代码来源:conditional-tags.php
示例8: wpsc_product_has_stock
/**
* wpsc product has stock function
* @return boolean - true if the product has stock or does not use stock, false if it does not
*/
function wpsc_product_has_stock($id = null)
{
global $wpdb;
// maybe do wpsc_clear_stock_claims first?
if (is_numeric($id) && $id > 0) {
$id = absint($id);
} else {
$id = get_the_ID();
}
$stock = get_post_meta($id, '_wpsc_stock', true);
if ($stock === '') {
return true;
}
$variations = get_children(array("post_type" => "wpsc-product", "post_parent" => $id));
$filter_name = empty($variations) ? 'wpsc_product_variation_stock' : 'wpsc_product_stock';
$stock = apply_filters($filter_name, (int) $stock, $id);
if (!empty($variations)) {
foreach ($variations as $variation) {
if (wpsc_product_has_stock($variation->ID)) {
return true;
}
}
} elseif ($stock > 0) {
$claimed_stock = $wpdb->get_var("SELECT SUM(`stock_claimed`) FROM `" . WPSC_TABLE_CLAIMED_STOCK . "` WHERE `product_id` IN({$id})");
if ($stock - $claimed_stock > 0) {
return true;
}
}
return false;
}
开发者ID:arturo-mayorga,项目名称:am_com,代码行数:34,代码来源:product-template.php
示例9: wpsc_check_variation_stock_availability
/**
* wpsc check variation stock availability function
* @return string - the product price
*/
function wpsc_check_variation_stock_availability($product_id, $variations)
{
global $wpdb;
$selected_post = (array) get_posts(array('post_parent' => $product_id, 'post_type' => "wpsc-product", 'post_status' => 'all', 'suppress_filters' => true));
foreach ($selected_post as $variation) {
$matches = 0;
$terms = wp_get_object_terms($variation->ID, 'wpsc-variation');
foreach ($terms as $term) {
if (in_array($term->term_id, $variations)) {
$matches++;
}
if ($matches == count($variations)) {
$the_selected_product = $variation->ID;
}
}
}
if (wpsc_product_has_stock($the_selected_product)) {
$stock = get_product_meta($the_selected_product, "stock", true);
$stock = apply_filters('wpsc_product_variation_stock', $stock, $id);
if (0 < $stock) {
return $stock;
}
} else {
$stock = get_product_meta($the_selected_product, "stock", true);
$stock = apply_filters('wpsc_product_variation_stock', $stock, $id);
if (is_numeric($stock)) {
$claimed_stock = $wpdb->get_var("SELECT SUM(`stock_claimed`) FROM `" . WPSC_TABLE_CLAIMED_STOCK . "` WHERE `product_id` IN('{$the_selected_product}')");
$stock = $stock - $claimed_stock;
return $stock;
}
}
return '';
}
开发者ID:hornet9,项目名称:Morato,代码行数:37,代码来源:product-template.php
示例10: wpsc_buy_now_button
/**
* wpsc buy now button code products function
* Sorry about the ugly code, this is just to get the functionality back, buy now will soon be overhauled, and this function will then be completely different
* @return string - html displaying one or more products
*/
function wpsc_buy_now_button($product_id, $replaced_shortcode = false)
{
$product_id = absint($product_id);
$product = get_post($product_id);
$supported_gateways = array('wpsc_merchant_paypal_standard', 'paypal_multiple');
$selected_gateways = get_option('custom_gateway_options');
if ($replaced_shortcode) {
ob_start();
}
if (in_array('wpsc_merchant_paypal_standard', (array) $selected_gateways)) {
if ($product_id > 0) {
$post_meta = get_post_meta($product_id, '_wpsc_product_metadata', true);
$shipping = isset($post_meta['shipping']) ? $post_meta['shipping']['local'] : '';
$price = get_post_meta($product_id, '_wpsc_price', true);
$special_price = get_post_meta($product_id, '_wpsc_special_price', true);
if ($special_price) {
$price = $special_price;
}
if (wpsc_uses_shipping()) {
$handling = get_option('base_local_shipping');
} else {
$handling = $shipping;
}
$has_variants = wpsc_product_has_variations($product_id) || !wpsc_product_has_stock($product_id);
$src = apply_filters('wpsc_buy_now_button_src', _x('https://www.paypal.com/en_US/i/btn/btn_buynow_LG.gif', 'PayPal Buy Now Button', 'wpsc'));
$classes = apply_filters('wpsc_buy_now_button_class', "wpsc-buy-now-form wpsc-buy-now-form-{$product_id}");
$classes_array = array_map('sanitize_html_class', explode(' ', $classes));
$classes = implode(' ', $classes_array);
$button_html = sprintf('<input%1$s class="wpsc-buy-now-button wpsc-buy-now-button-%2$s" type="image" name="submit" border="0" src="%3$s" alt="%4$s" />', disabled($has_variants, true, false), esc_attr($product_id), esc_url($src), esc_attr__('PayPal - The safer, easier way to pay online', 'wpsc'));
$button_html = apply_filters('wpsc_buy_now_button_html', $button_html, $product_id);
?>
<form class="<?php
echo $classes;
?>
" id="buy-now-product_<?php
echo $product_id;
?>
" target="paypal" action="<?php
echo esc_url(home_url());
?>
" method="post">
<input type="hidden" name="wpsc_buy_now_callback" value="1" />
<input type="hidden" name="product_id" value="<?php
echo esc_attr($product_id);
?>
" />
<?php
if ($has_variants) {
// grab the variation form fields here
$wpsc_variations = new wpsc_variations($product_id);
while (wpsc_have_variation_groups()) {
wpsc_the_variation_group();
printf('<input type="hidden" class="variation-value" name="variation[%1$d]" id="%2$s" value="0"/>', wpsc_vargrp_id(), wpsc_vargrp_form_id());
}
}
/* END wpsc_product_has_variations */
?>
<?php
if (get_option('multi_add')) {
?>
<label for="quantity"><?php
esc_html_e('Quantity', 'wpsc');
?>
</label>
<input type="text" size="4" id="quantity" class="wpsc-buy-now-quantity" name="quantity" value="" /><br />
<?php
} else {
?>
<input type="hidden" name="quantity" class="wpsc-buy-now-quantity" value="1" />
<?php
}
?>
<?php
echo $button_html;
?>
<img alt='' border='0' width='1' height='1' src='<?php
echo esc_url(_x('https://www.paypal.com/en_US/i/scr/pixel.gif', 'PayPal Pixel', 'wpsc'));
?>
' />
</form>
<?php
}
}
if ($replaced_shortcode) {
return ob_get_clean();
}
}
开发者ID:RJHanson292,项目名称:WP-e-Commerce,代码行数:92,代码来源:product.php
注:本文中的wpsc_product_has_stock函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论