示例#1
0
 /**
  * Displays a gift card code input widget
  *
  * @api `shopp('cart.applygiftcard')`
  * @since 1.3
  *
  * @param string    $result  The output
  * @param array     $options The options
  * - **before**: `<p class="error">` Markup to add before the widget
  * - **after**: `</p>` Markup to add after the widget
  * - **label**: The label to use for the submit button
  * - **autocomplete**: (on, off) Specifies whether an `<input>` element should have autocomplete enabled
  * - **accesskey**: Specifies a shortcut key to activate/focus an element. Linux/Windows: `[Alt]`+`accesskey`, Mac: `[Ctrl]``[Opt]`+`accesskey`
  * - **class**: The class attribute specifies one or more class-names for an element
  * - **disabled**: Specifies that an `<input>` element should be disabled
  * - **placeholder**: Specifies a short hint that describes the expected value of an `<input>` element
  * - **required**: Adds a class that specified an input field must be filled out before submitting the form, enforced by JS
  * - **tabindex**: Specifies the tabbing order of an element
  * - **title**: Specifies extra information about an element
  * @param ShoppCart $O       The working object
  * @return string The modified output
  **/
 public static function applygiftcard($result, $options, $O)
 {
     $defaults = array('before' => '<p class="error">', 'after' => '</p>', 'label' => Shopp::__('Add Gift Card'));
     $options = array_merge($defaults, $options);
     extract($options);
     $submit_attrs = array('title', 'value', 'disabled', 'tabindex', 'accesskey', 'class', 'autocomplete', 'placeholder', 'required');
     $result = '<div class="apply-giftcard">';
     $Errors = ShoppErrorStorefrontNotices();
     if ($Errors->exist()) {
         while ($Errors->exist()) {
             $result .= $before . $Errors->message() . $after;
         }
     }
     $result .= '<span><input type="text" id="giftcard" name="credit" value="" size="20" /></span>';
     $result .= '<span><input type="submit" id="apply-giftcard" name="giftcard" ' . inputattrs($options, $submit_attrs) . ' /></span>';
     $result .= '</div>';
     return $result;
 }
示例#2
0
 /**
  * Provides notice and error messages
  *
  * @api `shopp('storefront.errors')`
  * @since 1.0
  *
  * @param string          $result  The output
  * @param array           $options The options
  * - **before**: ` ` Markup to add before the list
  * - **after**: ` ` Markup to add after the list
  * @param ShoppStorefront $O       The working object
  * @return string The errors list
  **/
 public static function errors($result, $options, $O)
 {
     $Errors = ShoppErrorStorefrontNotices();
     if (!$Errors->exist()) {
         return false;
     }
     $defaults = array('before' => '<li>', 'after' => '</li>');
     $options = array_merge($defaults, $options);
     extract($options);
     $result = '';
     while ($Errors->exist()) {
         $result .= $before . $Errors->message() . $after;
     }
     return $result;
 }
示例#3
0
 public function content($content)
 {
     global $wp_query;
     // Test that this is the main query and it is the checkout page
     if (!$wp_query->is_main_query() || !is_shopp_page('checkout')) {
         return $content;
     }
     $Errors = ShoppErrors();
     do_action('shopp_init_checkout');
     ob_start();
     $Errors = ShoppErrorStorefrontNotices();
     if ($Errors->exist()) {
         echo ShoppStorefront::errors(array('errors-checkout.php', 'errors.php'));
     }
     locate_shopp_template(array('checkout.php'), true);
     $content = ob_get_clean();
     return apply_filters('shopp_checkout_page', $content);
 }
示例#4
0
 /**
  * Runs the shipping module calculations to populate the applicable shipping service rate options
  *
  * @author Jonathan Davis
  * @since 1.3
  *
  * @return void
  **/
 private function modules()
 {
     $Notices = ShoppErrorStorefrontNotices();
     $notices = $Notices->count();
     $services = array();
     // Run shipping module aggregate shipping calculations
     do_action_ref_array('shopp_calculate_shipping', array(&$services, ShoppOrder()));
     // No shipping options were generated, try fallback calculators for realtime rate failures
     if (empty($services) && $this->realtime) {
         do_action('shopp_calculate_fallback_shipping_init');
         do_action_ref_array('shopp_calculate_fallback_shipping', array(&$services, ShoppOrder()));
     }
     if (empty($services)) {
         return false;
     }
     // Still no rates, bail
     // Suppress new errors from shipping systems if there are services available
     $newnotices = $Notices->count() - $notices;
     if ($newnotices > 0) {
         $Notices->rollback($newnotices);
     }
     // Add all order shipping fees and item shipping fees
     foreach ($services as $service) {
         $service->amount += $this->fees($service);
     }
     parent::clear();
     $this->populate($services);
     // $this->sort('self::sort');
 }