Example #1
0
 /**
  * Provides the checkout page URL
  *
  * @api `shopp('checkout.url')`
  * @since 1.0
  *
  * @param string     $result  The output
  * @param array      $options The options
  * @param ShoppOrder $O       The working object
  * @return string The checkout page URL
  **/
 public static function url($result, $options, $O)
 {
     $link = Shopp::url(false, 'checkout', $O->security());
     $Storefront = ShoppStorefront();
     // Pass any arguments along
     $args = $_GET;
     unset($args['shopp_page'], $args['acct']);
     $link = esc_url(add_query_arg($args, $link));
     if (isset($Storefront->_confirm_page_content)) {
         $link = apply_filters('shopp_confirm_url', $link);
     } else {
         $link = apply_filters('shopp_checkout_url', $link);
     }
     return $link;
 }
Example #2
0
 /**
  * No longer necessary
  *
  * @deprecated No longer necessary
  *
  * @param string        $result  The output
  * @param array         $options The options
  * @param ShoppCustomer $O       The working object
  * @return string
  **/
 public static function process($result, $options, $O)
 {
     $Storefront = ShoppStorefront();
     return $Storefront->account['request'];
 }
Example #3
0
 public function smart(array $options = array())
 {
     $Storefront = ShoppStorefront();
     $viewed = isset($Storefront->viewed) ? array_filter($Storefront->viewed) : array();
     if (empty($viewed)) {
         $this->loading['where'] = 'true=false';
     }
     $this->loading['where'] = array("p.id IN (" . join(',', $viewed) . ")");
     if (isset($options['columns'])) {
         $this->loading['columns'] = $options['columns'];
     }
 }
Example #4
0
    /**
     * Handles rendering the [product-buynow] shortcode
     *
     * @author Jonathan Davis
     * @since 1.1
     *
     * @param array $attrs The parsed shortcode attributes
     * @return string The processed content
     **/
    static function buynow(array $atts = array())
    {
        $properties = array('name', 'slug', 'id');
        foreach ($properties as $prop) {
            if (!isset($atts[$prop])) {
                continue;
            }
            $Product = new ShoppProduct($atts[$prop], $prop);
        }
        if (!empty($Product->id)) {
            ShoppProduct($Product);
        } elseif (!isset(ShoppProduct()->id)) {
            return "";
        }
        ob_start();
        ?>
		<form action="<?php 
        shopp('cart.url');
        ?>
" method="post" class="shopp product">
			<input type="hidden" name="redirect" value="checkout" />
			<?php 
        if (isset($atts['variations'])) {
            ?>
				<?php 
            if (shopp('product.has-variations')) {
                ?>
				<ul class="variations">
					<?php 
                shopp('product.variations', 'mode=multiple&label=true&defaults=' . __('Select an option', 'Shopp') . '&before_menu=<li>&after_menu=</li>');
                ?>
				</ul>
				<?php 
            }
            ?>
			<?php 
        }
        ?>
			<?php 
        if (isset($atts['addons'])) {
            ?>
				<?php 
            if (shopp('product.has-addons')) {
                ?>
					<ul class="addons">
						<?php 
                shopp('product.addons', 'mode=menu&label=true&defaults=' . __('Select an add-on', 'Shopp') . '&before_menu=<li>&after_menu=</li>');
                ?>
					</ul>
				<?php 
            }
            ?>
			<?php 
        }
        ?>
			<p><?php 
        if (isset($atts['quantity'])) {
            $quantity = empty($atts['quantity']) ? 'class=selectall&input=menu' : html_entity_decode($atts['quantity']);
            ?>
				<?php 
            shopp('product.quantity', $quantity);
            ?>
			<?php 
        }
        ?>
			<?php 
        $button = 'label=' . (isset($atts['label']) ? $atts['label'] : __('Buy Now', 'Shopp'));
        $button .= isset($atts['ajax']) && Shopp::str_true($atts['ajax']) ? '&ajax=on' : '';
        if (isset($atts['button'])) {
            $button = html_entity_decode($atts['button']);
        }
        ?>
			<?php 
        shopp('product.addtocart', $button);
        ?>
</p>
		</form>
		<?php 
        $markup = ob_get_contents();
        ob_end_clean();
        ShoppStorefront()->shortcoded[] = get_the_ID();
        return apply_filters('shopp_buynow_shortcode', $markup);
    }
Example #5
0
 /**
  * Loads orders related to this customer
  *
  * @author Jonathan Davis
  * @since 1.3
  *
  * @param array $filters A list of SQL filter parameters
  * @return void
  **/
 public function load_orders(array $filters = array())
 {
     if (empty($this->id)) {
         return;
     }
     $Storefront = ShoppStorefront();
     if (isset($Storefront->account)) {
         extract((array) $Storefront->account);
     }
     if (!empty($id)) {
         $this->order($id);
     }
     $where = array("o.customer={$this->id}");
     if (isset($filters['where'])) {
         $where[] = $filters['where'];
     }
     $where = join(' AND ', $where);
     $orders = ShoppDatabaseObject::tablename(ShoppPurchase::$table);
     $query = "SELECT o.* FROM {$orders} AS o WHERE {$where} ORDER BY created DESC";
     $PurchaseLoader = new ShoppPurchase();
     $purchases = sDB::query($query, 'array', array($PurchaseLoader, 'loader'));
     $Storefront->purchases = (array) $purchases;
 }
Example #6
0
 /**
  * Iterates over the products in the collection
  *
  * @api `shopp('collection.products')`
  * @since 1.0
  *
  * @param string           $result  The output
  * @param array            $options The options
  * @param ShoppCollection $O       The working object
  * @return bool True if the next product exists, false otherwise
  **/
 public static function products($result, $options, $O)
 {
     if (isset($options['looping'])) {
         return isset($O->_product_loop);
     }
     $null = null;
     if (!isset($O->_product_loop)) {
         reset($O->products);
         ShoppProduct(current($O->products));
         $O->_pindex = 0;
         $O->_rindex = false;
         $O->_product_loop = true;
     } else {
         if ($Product = next($O->products)) {
             ShoppProduct($Product);
         }
         $O->_pindex++;
     }
     if (current($O->products) !== false) {
         return true;
     } else {
         unset($O->_product_loop);
         ShoppProduct($null);
         if (is_a(ShoppStorefront()->Requested, 'ShoppProduct')) {
             ShoppProduct(ShoppStorefront()->Requested);
         }
         $O->_pindex = 0;
         return false;
     }
 }
Example #7
0
 /**
  * Adds JavaScript to be included in the footer on shopping pages
  *
  * @author Jonathan Davis
  * @since 1.1
  *
  * @param string $script JavaScript fragment
  * @param boolean $global (optional) Include the script in the global namespace
  * @return void
  **/
 public static function add_storefrontjs($script, $global = false)
 {
     $Storefront = ShoppStorefront();
     if ($Storefront === false) {
         return;
     }
     if ($global) {
         if (!isset($Storefront->behaviors['global'])) {
             $Storefront->behaviors['global'] = array();
         }
         $Storefront->behaviors['global'][] = trim($script);
     } else {
         $Storefront->behaviors[] = $script;
     }
 }
Example #8
0
 /**
  * Provides the current account menu item from the account-menu loop
  *
  * @api `shopp('storefront.account-menuitem')`
  * @since 1.2
  *
  * @param string          $result  The output
  * @param array           $options The options
  * @param ShoppStorefront $O       The working object
  * @return string The account menu item entry
  **/
 public static function account_menuitem($result, $options, $O)
 {
     $Storefront = ShoppStorefront();
     $page = current($Storefront->menus);
     if (array_key_exists('url', $options)) {
         return add_query_arg($page->request, '', Shopp::url(false, 'account'));
     }
     if (array_key_exists('action', $options)) {
         return $page->request;
     }
     if (array_key_exists('classes', $options)) {
         $classes = array($page->request);
         if ($Storefront->account['request'] == $page->request) {
             $classes[] = 'current';
         }
         return join(' ', $classes);
     }
     if (array_key_exists('current', $options) && $Storefront->account['request'] == $page->request) {
         return true;
     }
     return $page->label;
 }
Example #9
0
 /**
  * Provides the URL for the referring page
  *
  * The referrer is the page the shopper was visiting before being
  * sent to the cart page. If no referring page is available, the
  * catalog page URL is given instead.
  *
  * @api `shopp('cart.referrer')`
  * @since 1.1
  *
  * @param string    $result  The output
  * @param array     $options The options
  * @param ShoppCart $O       The working object
  * @return string The referring page's URL
  **/
 public static function referrer($result, $options, $O)
 {
     $referrer = ShoppStorefront()->referrer;
     if (!$referrer) {
         $referrer = shopp('catalog', 'url', 'return=1');
     }
     return $referrer;
 }