/** * Returns an array containing one or more values representing possible product weight (this might be one or multiple * weights if for instance the product has variants). The returned array is indexed on the variant ID where appropriate. * If there are no variants the actual product weight will have a zero index. * * @param $product ID or existing product object * @return array */ function shopp_product_weights($product) { if (!is_a($product, 'ShoppProduct')) { $product = shopp_product($product); } if (false === $product) { shopp_debug(__FUNCTION__ . ' failed: a valid product object or product ID must be specified.'); return false; } $weights = array(); foreach ($product->prices as $price) { $weight = isset($price->dimensions['weight']) ? $price->dimensions['weight'] : 0; if ('product' === $price->context) { $weights[0] = $weight; } if ('variation' === $price->context) { $weights[$price->id] = $weight; } } if (count($weights) > 1) { unset($weights[0]); } // Do not return the 'base' weight if there are variants return $weights; }
* @version 4.2 * * @var bool $must_login */ $is_there_any_product = false; $is_there_any_product_to_sell = false; ob_start(); ?> <form action="<?php echo esc_url(shopp('cart.url')); ?> " class="cart" method="post" enctype="multipart/form-data"> <table width="100%" class="tribe-events-tickets"> <?php foreach ($tickets as $ticket) { $product = shopp_product($ticket->ID); $in_stock = 'off' === $product->inventory || $product->stock > $product->qty_sold ? true : false; if ($ticket->date_in_range(current_time('timestamp'))) { $is_there_any_product = true; echo sprintf('<input type="hidden" name="product_id[]" value="%d">', esc_attr($ticket->ID)); echo '<tr>'; echo '<td width="75" class="shopp quantity" data-product-id="' . esc_attr($ticket->ID) . '">'; if ($in_stock) { echo $this->quantity_selector($product); $is_there_any_product_to_sell = true; $remaining = $ticket->remaining(); if ($remaining) { ?> <span class="tribe-tickets-remaining"> <?php echo sprintf(esc_html__('%1$s out of %2$s available', 'event-tickets-plus'), esc_html($remaining), esc_html($ticket->original_stock()));
/** * Gets the product price in the correct money format per store settings. * * @param int|object $product * @return string */ public function get_price_html($product) { $product = shopp_product($product); if (false === $product) { return ''; } return Shopp::money($this->get_single_price($product)); }