/**
  * Renders the errors template
  *
  * @author Jonathan Davis
  * @since 1.1
  *
  * @return string The processed errors.php template file
  **/
 static function errors(array $templates = array('errors.php'))
 {
     ob_start();
     locate_shopp_template($templates, true);
     $content = ob_get_clean();
     return apply_filters('shopp_storefront_errors', $content);
 }
Exemple #2
0
 /**
  * Provides new account registration error messages
  *
  * @api `shopp('customer.registration-errors')`
  * @since 1.2
  *
  * @param string        $result  The output
  * @param array         $options The options
  * @param ShoppCustomer $O       The working object
  * @return string The error markup
  **/
 public static function registration_errors($result, $options, $O)
 {
     $Errors = ShoppErrors();
     if (!$Errors->exist(SHOPP_ERR)) {
         return false;
     }
     ob_start();
     locate_shopp_template(array('errors.php'), true);
     return ob_get_clean();
 }
Exemple #3
0
 public function receipt($template = 'receipt.php')
 {
     if (empty($this->purchased)) {
         $this->load_purchased();
     }
     if ('receipt.php' == $template) {
         // If not overridden
         $context = ShoppStorefront::intemplate();
         // Set receipt context
         if (!empty($context)) {
             $template = "receipt-{$context}";
         }
     }
     ob_start();
     locate_shopp_template(array($template, 'receipt.php'), true);
     $content = ob_get_clean();
     return apply_filters('shopp_order_receipt', $content);
 }
Exemple #4
0
 /**
  * Displays the side cart widget
  *
  * The side cart widget shows a small summarized version of the
  * shopping cart. It uses the `sidecart.php` Shopp content template
  * for markup and layout.
  *
  * @api `shopp('cart.sidecart')`
  * @since 1.1
  *
  * @param string    $result  The output
  * @param array     $options The options
  * @param ShoppCart $O       The working object
  * @return string The markup for the sidecart widget
  **/
 public static function sidecart($result, $options, $O)
 {
     if (!shopp_setting_enabled('shopping_cart')) {
         return '';
     }
     ob_start();
     locate_shopp_template(array('sidecart.php'), true);
     return ob_get_clean();
 }
Exemple #5
0
 /**
  * Generates the shopping cart summary markup from the `summary.php` template file
  *
  * @api `shopp('checkout.cart-summary')`
  * @since 1.0
  *
  * @param string     $result  The output
  * @param array      $options The options
  * @param ShoppOrder $O       The working object
  * @return string The generated cart summary markup
  **/
 public static function cart_summary($result, $options, $O)
 {
     $templates = array('summary.php');
     $context = ShoppStorefront::intemplate();
     // Set summary context
     if (!empty($context)) {
         // Prepend the summary-context.php template file
         array_unshift($templates, "summary-{$context}");
     }
     ob_start();
     locate_shopp_template($templates, true);
     $content = ob_get_clean();
     // If inside the checkout form, strip the extra <form> tag so we don't break standards
     // This is ugly, but necessary given the different markup contexts the cart summary is used in
     if ('checkout.php' == $context) {
         $content = preg_replace('/<\\/?form.*?>/', '', $content);
     }
     return $content;
 }
Exemple #6
0
 public function content($content)
 {
     global $wp_query;
     // Only modify content for Shopp collections (Shopp smart collections and taxonomies)
     if (!$wp_query->is_main_query() || !is_shopp_collection()) {
         return $content;
     }
     remove_filter('the_content', array($this, 'content'), 20);
     $Collection = ShoppCollection();
     ob_start();
     if (empty($Collection)) {
         locate_shopp_template(array('catalog.php'), true);
     } else {
         $templates = array('category.php', 'collection.php');
         $ids = array('slug', 'id');
         foreach ($ids as $property) {
             if (isset($Collection->{$property})) {
                 $id = $Collection->{$property};
             }
             array_unshift($templates, 'category-' . $id . '.php', 'collection-' . $id . '.php');
         }
         locate_shopp_template($templates, true);
     }
     $content = ob_get_clean();
     return apply_filters('shopp_category_template', $content);
 }
 /**
  * Provides schema.org markup for the current product
  *
  * A built-in schema template is used unless a custom
  * scheme template is defined in the active Shopp
  * content templates:
  *
  * - product-{slug}-schema.php
  * - product-schema.php
  * - built-in template
  *
  * @api `shopp('product.schema')`
  * @since 1.3
  *
  * @param string       $result  The output
  * @param array        $options The options
  * @param ShoppProduct $O       The working object
  * @return string The schema.org markup
  **/
 public static function schema($result, $options, $O)
 {
     $template = locate_shopp_template(array('product-' . $O->slug . '-schema.php', 'product-schema.php'));
     if (!$template) {
         $template = SHOPP_ADMIN_PATH . '/products/schema.php';
     }
     ob_start();
     include $template;
     return ob_get_clean();
 }
Exemple #8
0
 /**
  * Provides markup for a menu of faceted filter options to find products in the current category
  *
  * @api `shopp('collection.faceted-menu')`
  * @since 1.2
  *
  * @param string          $result  The output
  * @param array           $options The options
  * @param ShoppCollection $O       The working object
  * @return string Markup of the faceted menu for the collection
  **/
 public static function faceted_menu($result, $options, $O)
 {
     $_ = array();
     // Use a template if available
     $template = locate_shopp_template(array('facetedmenu-' . $O->slug . '.php', 'facetedmenu.php'));
     if ($template) {
         ob_start();
         include $template;
         return ob_get_clean();
     }
     if (self::is_facet_filtered('', false, $O)) {
         $_[] = '<ul>';
         while (self::facet_filters(false, false, $O)) {
             $_[] = '<li>';
             $_[] = '<strong>' . self::facet_name(false, false, $O) . ':</strong> ';
             $_[] = self::facet_filter(false, false, $O);
             $_[] = sprintf(' <a href="%s" class="shoppui-remove-sign cancel"><span class="hidden">%s</span></a>', self::facet_link(false, false, $O), Shopp::__('Remove Filter'));
             $_[] = '</li>';
         }
         $_[] = '</ul>';
     }
     $_[] = '<ul class="faceted-menu">';
     while (self::facet_menus(false, false, $O)) {
         if (self::facet_filtered(false, false, $O)) {
             continue;
         }
         if (!self::facet_menu_has_options(false, false, $O)) {
             continue;
         }
         $_[] = '<li>';
         $_[] = '<h4>' . self::facet_name(false, false, $O) . '</h4>';
         $_[] = '<ul class="facet-option ' . self::facet_slug(false, false, $O) . '">';
         while (self::facet_options(false, false, $O)) {
             $_[] = '<li>';
             $_[] = sprintf('<a href="%s">%s</a>', esc_url(self::facet_option_link(false, false, $O)), self::facet_option_label(false, false, $O));
             $_[] = ' <span class="count">' . self::facet_option_count(false, false, $O) . '</span>';
             $_[] = '</li>';
         }
         $_[] = '</ul>';
         $_[] = '</li>';
     }
     $_[] = '</ul>';
     return join('', $_);
 }
Exemple #9
0
 /**
  * Provides markup for displaying one or more products in an aside widget
  *
  * @api `shopp('storefront.side-product')`
  * @since 1.0
  *
  * @param string          $result  The output
  * @param array           $options The options
  * - **source**: `product` (product,category) The source of the products to display
  * - **product**: The product custom post-type database ID or list of IDs (comma-separated)
  * - **category**: The taxonomy term ID or list of IDs (comma-separated)
  * - **load**: (on) When set, this option will load the first product (or category) into the working product or category context
  * @param ShoppStorefront $O       The working object
  * @return string The widget markup
  **/
 public static function side_product($result, $options, $O)
 {
     $Shopp = Shopp::object();
     $content = false;
     $source = isset($options['source']) ? $options['source'] : 'product';
     if ($source == 'product' && isset($options['product'])) {
         // Save original requested product
         if ($Shopp->Product) {
             $Requested = $Shopp->Product;
         }
         $products = explode(',', $options['product']);
         if (!is_array($products)) {
             $products = array($products);
         }
         foreach ($products as $product) {
             $product = trim($product);
             if (empty($product)) {
                 continue;
             }
             if (preg_match('/^\\d+$/', $product)) {
                 $Shopp->Product = new ShoppProduct($product);
             } else {
                 $Shopp->Product = new ShoppProduct($product, 'slug');
             }
             if (empty($Shopp->Product->id)) {
                 continue;
             }
             if (isset($options['load'])) {
                 return true;
             }
             ob_start();
             locate_shopp_template(array('sideproduct-' . $Shopp->Product->id . '.php', 'sideproduct.php'), true);
             $content .= ob_get_clean();
         }
         // Restore original requested Product
         if (!empty($Requested)) {
             $Shopp->Product = $Requested;
         } else {
             $Shopp->Product = false;
         }
     }
     if ($source == 'category' && isset($options['category'])) {
         // Save original requested category
         if ($Shopp->Category) {
             $Requested = $Shopp->Category;
         }
         if ($Shopp->Product) {
             $RequestedProduct = $Shopp->Product;
         }
         if (empty($options['category'])) {
             return false;
         }
         if (in_array($options['category'], array_keys($Shopp->Collections))) {
             $Category = ShoppCatalog::load_collection($options['category'], $options);
             ShoppCollection($Category);
         } elseif (intval($options['category']) > 0) {
             // By ID
             ShoppCollection(new ProductCategory($options['category']));
         } else {
             ShoppCollection(new ProductCategory($options['category'], 'slug'));
         }
         if (isset($options['load'])) {
             return true;
         }
         $options['load'] = array('coverimages');
         ShoppCollection()->load($options);
         $template = locate_shopp_template(array('sideproduct-' . $Shopp->Category->slug . '.php', 'sideproduct.php'));
         ob_start();
         foreach (ShoppCollection()->products as &$product) {
             ShoppProduct($product);
             load_template($template, false);
         }
         $content = ob_get_clean();
         // Restore original requested category
         if (!empty($Requested)) {
             $Shopp->Category = $Requested;
         } else {
             $Shopp->Category = false;
         }
         if (!empty($RequestedProduct)) {
             $Shopp->Product = $RequestedProduct;
         } else {
             $Shopp->Product = false;
         }
     }
     return $content;
 }