Пример #1
0
 /**
  * Return the HTML for rendering the add to cart buton for the given product id
  */
 public static function getCartButton(Cart66Product $product, $attrs)
 {
     $view = "<p>" . __("Could not load product information", "cart66") . "</p>";
     if ($product->id > 0) {
         // Set CSS style if available
         $style = isset($attrs['style']) ? 'style="' . $attrs['style'] . '"' : '';
         $price = '';
         $quantity = isset($attrs['quantity']) ? $attrs['quantity'] : 1;
         $ajax = isset($attrs['ajax']) ? $attrs['ajax'] : 'no';
         $buttonText = isset($attrs['text']) ? $attrs['text'] : __('Add to Cart', 'cart66');
         $showName = isset($attrs['show_name']) ? strtolower($attrs['show_name']) : '';
         $showPrice = isset($attrs['showprice']) ? strtolower($attrs['showprice']) : 'yes';
         $subscription = 0;
         if ($showPrice == 'yes' || $showPrice == 'only') {
             $price = $product->price;
             // Check for subscription pricing
             if ($product->isSubscription()) {
                 if ($product->isPayPalSubscription()) {
                     $subscription = 1;
                     Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Rendering button for PayPal subscription");
                     $sub = new Cart66PayPalSubscription($product->id);
                     $price = $sub->getPriceDescription($sub->offerTrial > 0, '(trial)');
                 } else {
                     $subscription = 2;
                     if ($product->price > 0) {
                         $price .= ' + ' . $product->getRecurringPriceSummary();
                     } else {
                         $price = $product->getRecurringPriceSummary();
                     }
                 }
             } else {
                 $price = $product->getPriceDescription();
             }
         }
         if ($product->isSubscription()) {
             if ($product->isPayPalSubscription()) {
                 $subscription = 1;
             } else {
                 $subscription = 2;
             }
         }
         $gravity_form_id = isset($product->gravity_form_id) ? $product->gravity_form_id : false;
         $data = array('price' => $price, 'is_user_price' => $product->is_user_price, 'min_price' => $product->min_price, 'max_price' => $product->max_price, 'quantity' => $quantity, 'ajax' => $ajax, 'showPrice' => $showPrice, 'showName' => $showName, 'style' => $style, 'buttonText' => $buttonText, 'subscription' => $subscription, 'addToCartPath' => self::getAddToCartImagePath($attrs), 'product' => $product, 'productOptions' => $product->getOptions(), 'gravity_form_id' => $gravity_form_id);
         $view = Cart66Common::getView('views/cart-button.php', $data, true, true);
     }
     return $view;
 }
 public function accountCreate($attrs)
 {
     $render_form = false;
     if (isset($attrs['product'])) {
         $product = new Cart66Product();
         $product->load($attrs['product']);
         if ($product->id <= 0) {
             $product->loadByItemNumber($attrs['product']);
         }
         if ($product->isMembershipProduct() || $product->isPayPalSubscription()) {
             $render_form = true;
         }
     }
     $data = array('attrs' => $attrs, 'render_form' => $render_form);
     $view = Cart66Common::getView('pro/views/account-create.php', $data);
     return $view;
 }
Пример #3
0
 /**
  * Return the PayPal subscription id if the product is a PayPal subscription product. 
  * Otherwise return false.
  */
 public function getPayPalSubscriptionId()
 {
     $subId = false;
     $product = new Cart66Product($this->_productId);
     if ($product->isPayPalSubscription()) {
         $subId = $product->id;
         // Note: Products and PayPal subscriptions share the same database table
     }
     return $subId;
 }