/** * 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; }
/** * Create a recurring payments profile * The initial payment is charged with DoExpressCheckout so that the first payment is received immediately */ public function CreateRecurringPaymentsProfile($token, $cartItem, $index) { $plan = new Cart66PayPalSubscription($cartItem->getPayPalSubscriptionId()); $queryString = array('TOKEN' => $token, 'METHOD' => 'CreateRecurringPaymentsProfile', 'PROFILESTARTDATE' => date('Y-m-d\\Tg:i:s', strtotime($plan->getStartTimeFormula(), Cart66Common::localTs())), 'BILLINGPERIOD' => ucwords(rtrim($plan->billingIntervalUnit, 's')), 'BILLINGFREQUENCY' => $plan->billingInterval, 'TOTALBILLINGCYCLES' => $plan->billingCycles, 'AMT' => $plan->price, 'INITAMT' => 0, 'CURRENCYCODE' => CURRENCY_CODE, 'FAILEDINITAMTACTION' => 'CancelOnFailure', 'L_BILLINGTYPE' . $index => 'RecurringPayments', 'DESC' => $plan->name . ' ' . str_replace(' ', ' ', strip_tags($plan->getPriceDescription($plan->offerTrial > 0, '(trial)')))); if ($plan->offerTrial == 1) { $queryString['TRIALBILLINGPERIOD'] = ucwords(rtrim($plan->trialPeriodUnit, 's')); $queryString['TRIALBILLINGFREQUENCY'] = $plan->trialPeriod; $queryString['TRIALAMT'] = $plan->trialPrice; $queryString['TRIALTOTALBILLINGCYCLES'] = $plan->trialCycles; } $params = array(); $queryString = array_merge($this->_apiData, $queryString); foreach ($queryString as $key => $value) { $params[] = $key . '=' . urlencode($value); } $nvp = implode('&', $params); Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Creating recurring payments profile NVP: " . str_replace('&', "\n", $nvp)); $result = $this->_decodeNvp($this->_sendRequest($this->_apiEndPoint, $nvp)); Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Creating recurring payments raw result: " . print_r($result, true)); return $result; }
public static function paypalSubscriptionsTable() { $columns = array('id', 'item_number', 'name', 'feature_level', 'setup_fee', 'price', 'billing_cycles', 'offer_trial', 'start_recurring_number', 'start_recurring_unit'); $indexColumn = "id"; $tableName = Cart66Common::getTableName('products'); $where = self::dataTablesWhere($columns); $limit = self::dataTablesLimit() == '' ? null : self::dataTablesLimit(); $order = self::dataTablesOrder($columns); if ($where == null) { $where = "WHERE is_paypal_subscription>0"; } else { $where .= " AND is_paypal_subscription>0"; } $iTotal = self::totalRows($indexColumn, $tableName, $where); $iFilteredTotal = self::filteredRows($indexColumn, $tableName, $where); $data = array(); $subscription = new Cart66PayPalSubscription(); $subscriptions = $subscription->getModels($where, $order, $limit); foreach ($subscriptions as $s) { $gfTitles = self::gfData(); if ($s->gravityFormId > 0 && isset($gfTitles) && isset($gfTitles[$s->gravityFormId])) { $gfTitles = '<br/><em>Linked To Gravity Form: ' . $gfTitles[$s->gravityFormId] . '</em>'; } else { $gfTitles = ''; } $data[] = array($s->id, $s->item_number, $s->name . $gfTitles, $s->featureLevel, Cart66Common::currency($s->setupFee), $s->getPriceDescription(false), $s->getBillingCycleDescription(), $s->getTrialPriceDescription(), $s->getStartRecurringDescription()); } Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] " . json_encode($data)); $array = array('sEcho' => $_GET['sEcho'], 'iTotalRecords' => $iTotal[0], 'iTotalDisplayRecords' => $iFilteredTotal[0], 'aaData' => $data); echo json_encode($array); die; }
public static function paypalSubscriptions() { $data = array(); if (CART66_PRO) { $sub = new Cart66PayPalSubscription(); $data['subscription'] = $sub; if ($_SERVER['REQUEST_METHOD'] == 'POST' && Cart66Common::postVal('cart66-action') == 'save paypal subscription') { $subData = Cart66Common::postVal('subscription'); $subData['setup_fee'] = isset($subData['setup_fee']) ? Cart66Common::convert_currency_to_number($subData['setup_fee']) : ''; $subData['price'] = isset($subData['price']) ? Cart66Common::convert_currency_to_number($subData['price']) : ''; $sub->setData($subData); $errors = $sub->validate(); if (count($errors) == 0) { $sub->save(); $sub->clear(); $data['subscription'] = $sub; } else { $data['errors'] = $sub->getErrors(); $data['jqErrors'] = $sub->getJqErrors(); } } else { if (Cart66Common::getVal('task') == 'edit' && isset($_GET['id'])) { $sub->load(Cart66Common::getVal('id')); $data['subscription'] = $sub; } elseif (Cart66Common::getVal('task') == 'delete' && isset($_GET['id'])) { $sub->load(Cart66Common::getVal('id')); $sub->deleteMe(); $sub->clear(); $data['subscription'] = $sub; } } $data['plans'] = $sub->getModels('where is_paypal_subscription>0', 'order by name', '1'); $view = Cart66Common::getView('pro/admin/paypal-subscriptions.php', $data); echo $view; } else { echo '<h2>PayPal Subscriptions</h2><p class="description">This feature is only available in <a href="http://cart66.com">Cart66 Professional</a>.</p>'; } }
Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Bypassing DoExpressCheckout because item amount is not greater than zero: {$itemTotal}"); $response['ACK'] = 'SUCCESS'; // Forcing success since DoExpressCheckout wasn't called } $ack = strtoupper($response['ACK']); if ('SUCCESS' == $ack || 'SUCCESSWITHWARNING' == $ack) { // Wait to make sure the transaction is a success before creating the account if ($createAccount) { Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Creating account after successful PayPal transaction"); $account->save(); } // Create Recurring Payment Profile if a subscription has been sold $profileResponse = array('ACK' => 'SKIPPED'); if ($cartItem = Cart66Session::get('Cart66Cart')->getPayPalSubscriptionItem()) { $planIndex = Cart66Session::get('Cart66Cart')->getPayPalSubscriptionIndex(); $plan = new Cart66PayPalSubscription($cartItem->getPayPalSubscriptionId()); $profileResponse = $pp->CreateRecurringPaymentsProfile($token, $cartItem, $planIndex); if ('FAILURE' != strtoupper($profileResponse['ACK'])) { $paypalPaymentProfileId = $profileResponse['PROFILEID']; if (Cart66Common::isLoggedIn() && $account->isPayPalAccount()) { // Expire the current subscription and attach a new subscription $account->cancelSubscription('Your subscription has been canceled because you changed to a new subscription.', true); } $activeUntil = $plan->getStartTimeFormula(); $account->attachPayPalSubscription($details, $paypalPaymentProfileId, $plan, $activeUntil); } } elseif ($cartItem = Cart66Session::get('Cart66Cart')->getMembershipProductItem()) { Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Got membership product from the cart after a PayPal transaction."); $product = new Cart66Product($cartItem->getProductId()); $account->attachMembershipProduct($product, $details['FIRSTNAME'], $details['LASTNAME']); }
public function getProductPriceDescription() { if ($this->_productId > 0) { $product = new Cart66Product($this->_productId); if ($product->isPayPalSubscription()) { $product = new Cart66PayPalSubscription($product->id); $priceDescription = $product->getPriceDescription($product->offerTrial > 0, '(trial)'); } elseif ($product->isSpreedlySubscription()) { $product = new Cart66Product($product->id); $priceDescription = $product->getPriceDescription(); } elseif ($product->is_user_price == 1 || $product->gravity_form_pricing) { $session_var_name = "userPrice_{$this->_productId}"; if ($product->gravity_form_pricing) { $session_var_name .= '_' . $this->getFirstFormEntryId(); } if (Cart66Session::get($session_var_name)) { $userPrice = Cart66Session::get($session_var_name); if ($product->min_price > 0 && $userPrice < $product->min_price) { $userPrice = $product->min_price; } if ($product->max_price > 0 && $userPrice > $product->max_price) { $userPrice = $product->max_price; } $priceDescription = Cart66Common::currency($userPrice); } else { $priceDescription = Cart66Common::currency($product->price); } } else { $priceDescription = $product->getPriceDescription($this->_priceDifference); if (is_numeric($priceDescription)) { $priceDescription = Cart66Common::currency($priceDescription); } } } return $priceDescription; }
public static function shortcodeProductsTable() { global $wpdb; $prices = array(); $types = array(); //$options=''; $postId = Cart66Common::postVal('id'); $product = new Cart66Product(); $products = $product->getModels("where id={$postId}", "order by name"); $data = array(); foreach ($products as $p) { if ($p->itemNumber == "") { $type = 'id'; } else { $type = 'item'; } $types[] = htmlspecialchars($type); if (CART66_PRO && $p->isPayPalSubscription()) { $sub = new Cart66PayPalSubscription($p->id); $subPrice = strip_tags($sub->getPriceDescription($sub->offerTrial > 0, '(trial)')); $prices[] = htmlspecialchars($subPrice); Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] subscription price in dialog: {$subPrice}"); } else { $prices[] = htmlspecialchars(strip_tags($p->getPriceDescription())); } //$options .= '<option value="'.$id.'">'.$p->name.' '.$description.'</option>'; $data[] = array('type' => $types, 'price' => $prices, 'item' => $p->itemNumber); } echo json_encode($data); die; }
/** * Create a new account with the given details for the new plan. * The account is initially set to be active until one day from creation unless otherwise specified using the $activeUntil parameter. * * @param array $details The PayPal details from the express checkout details * @param string $profileId The PayPal billing profile id * @param Cart66PayPalSubscription $plan The plan for the subscription * @param string String suitable for use with strtotime * @return int The id of the new account or FALSE if the account creation failed */ public function attachPayPalSubscription($details, $profileId, $plan, $activeUntil = null) { $id = false; if ($this->id > 0) { // Create new account $interval = $plan->billingInterval . ' ' . $plan->getBillingIntervalUnit(); // Define initial expiration date $activeUntil = isset($activeUntil) ? date('Y-m-d H:i:s', strtotime($activeUntil)) : date('Y-m-d H:i:s', strtotime('+ 1 day', Cart66Common::localTs())); $data = array('account_id' => $this->id, 'billing_first_name' => $details['FIRSTNAME'], 'billing_last_name' => $details['LASTNAME'], 'paypal_billing_profile_id' => $profileId, 'subscription_plan_name' => $plan->name, 'feature_level' => $plan->featureLevel, 'active_until' => $activeUntil, 'billing_interval' => $interval, 'status' => 'active', 'active' => 0, 'product_id' => $plan->id); $subscription = new Cart66AccountSubscription(); $subscription->setData($data); $subscription->save(); } }
public function drawFeatureLevelMetaBox($post) { if (CART66_PRO) { $plans = array(); $featureLevels = array(); $data = array(); // Load feature levels defined in Spreedly if available if (class_exists('SpreedlySubscription')) { $sub = new SpreedlySubscription(); $subs = $sub->getSubscriptions(); foreach ($subs as $s) { // $plans[] = array('feature_level' => (string)$s->featureLevel, 'name' => (string)$s->name); $plans[(string) $s->name] = (string) $s->featureLevel; $featureLevels[] = (string) $s->featureLevel; } } // Load feature levels defined in PayPal subscriptions $sub = new Cart66PayPalSubscription(); $subs = $sub->getSubscriptionPlans(); foreach ($subs as $s) { $plans[$s->name] = $s->featureLevel; $featureLevels[] = $s->featureLevel; } // Load feature levels defined in Membership products foreach (Cart66Product::getMembershipProducts() as $membership) { $plans[$membership->name] = $membership->featureLevel; $featureLevels[] = $membership->featureLevel; } // Put unique feature levels in alphabetical order if (count($featureLevels)) { $featureLevels = array_unique($featureLevels); sort($featureLevels); $savedPlanCsv = get_post_meta($post->ID, '_cart66_subscription', true); $savedFeatureLevels = empty($savedPlanCsv) ? array() : explode(',', $savedPlanCsv); Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Cart66 Saved Plans: {$savedPlanCsv} -- " . print_r($savedFeatureLevels, true)); $data = array('featureLevels' => $featureLevels, 'plans' => $plans, 'saved_feature_levels' => $savedFeatureLevels); } $box = Cart66Common::getView('pro/views/feature-level-meta-box.php', $data); echo $box; } }
public function getPriceDescription($priceDifference = 0) { if ($this->id > 0) { if ($this->isSpreedlySubscription()) { $price = $this->price + $priceDifference; $priceDescription = ""; if ($price > 0) { $priceDescription = $price; } if ($this->hasFreeTrial()) { if (empty($this->priceDescription)) { $priceDescription = "Free Trial"; } else { $priceDescription = $this->priceDescription; } } else { $priceDescription = Cart66Common::currency($priceDescription); if ($price > 0) { $priceDescription .= ' (one time) +<br/> '; } else { $priceDescription = ''; } $priceDescription .= $this->getSubscriptionPriceSummary(); } $proRated = $this->getProRateInfo(); if (is_object($proRated) && $proRated->amount > 0) { $proRatedInfo = $proRated->description . ': ' . $proRated->money; $priceDescription .= '<br/>' . $proRatedInfo; } } elseif ($this->isPayPalSubscription()) { $plan = new Cart66PayPalSubscription($this->id); $priceDescription = ''; if ($plan->offerTrial) { $priceDescription .= $plan->getTrialPriceDescription(); } else { $priceDescription .= $plan->getPriceDescription(); } } else { // Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Product custom price description: $this->priceDes"); if (!empty($this->priceDescription)) { $priceDescription = $this->priceDescription; } else { $priceDescription = $this->price + $priceDifference; } } } return $priceDescription; }
public static function add_shortcode_popup() { global $current_screen; //Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Thinking about adding code for shortcode popup: $current_screen->id"); $add_popup = false; if (in_array($current_screen->id, Cart66Dialog::cart66_get_popup_screens())) { $add_popup = true; } if ($add_popup) { Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Adding code for shortcode popup"); } else { return; } ?> <link type="text/css" rel="stylesheet" href="<?php echo CART66_URL; ?> /js/cart66.css" /> <script language="javascript" type="text/javascript"> <?php $prices = array(); $types = array(); $options = ''; $products = Cart66Product::loadProductsOutsideOfClass(); //$products = $product->getModels("where id>0", "order by name"); if (count($products)) { $i = 0; foreach ($products as $p) { $optionClasses = ""; if ($p->item_number == "") { $id = $p->id; $type = 'id'; $description = ""; } else { $id = $p->item_number; $type = 'item'; $description = '(# ' . $p->item_number . ')'; } $types[] = htmlspecialchars($type); if (CART66_PRO && $p->is_paypal_subscription == 1) { $sub = new Cart66PayPalSubscription($p->id); $subPrice = strip_tags($sub->getPriceDescription($sub->offerTrial > 0, '(trial)')); $prices[] = htmlspecialchars($subPrice); $optionClasses .= " subscriptionProduct "; //Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] subscription price in dialog: $subPrice"); } else { $priceDescription = __('Price:', 'cart66') . ' ' . Cart66Common::currency($p->price); if ($p->price_description != null) { $priceDescription = $p->price_description; } $prices[] = htmlspecialchars(strip_tags($priceDescription)); } $options .= '<option value="' . $id . '" class="' . $optionClasses . '">' . $p->name . ' ' . $description . '</option>'; $i++; } } else { $options .= '<option value="">' . __('No Products', 'cart66') . '</option>'; } $prodTypes = implode("\",\"", $types); $prodPrices = implode("\",\"", $prices); ?> var prodtype = new Array("<?php echo $prodTypes; ?> "); var prodprices = new Array("<?php echo $prodPrices; ?> "); function insertProductCode(){ var type = prodtype[jQuery("#productNameSelector option:selected").index()]; var prod = jQuery("#productNameSelector option:selected").val(); if(jQuery("#productStyle").val()!=""){ var style = 'style="'+jQuery("#productStyle").val()+'"'; } else { var style = ''; } if(jQuery("#buttonText").val()!=""){ var text = 'text="'+jQuery("#buttonText").val()+'"'; } else { var text = ''; } var quantity = jQuery("input:radio[name=quantityOptions]:checked").val(); var defaultQuantity = jQuery("#defaultQuantity").val(); if(quantity == 'user') { if(defaultQuantity == ''){ var quantity = 'quantity="user"'; } else { var quantity = 'quantity="user:'******'"'; } } else if(quantity == 'pre'){ var quantity = 'quantity="'+defaultQuantity+'"'; } else { var quantity = ''; } if(jQuery("#productNameSelector option:selected").hasClass('subscriptionProduct')){ var quantity = ''; } var ajax = jQuery("input:radio[name=ajaxOptions]:checked").val(); if(ajax == 'yes') { var ajax = 'ajax="yes"'; } else { var ajax = ''; } var showPrice = jQuery("input:radio[name=showPrice]:checked").val(); if(showPrice == 'no') { var showPrice = 'showprice="no"'; } else if(showPrice == 'only'){ var showPrice = 'showprice="only"'; } else { var showPrice = ''; } var buttonImage = ''; if(jQuery("#buttonImage").val() != "") { var buttonImage = 'img="' + jQuery("#buttonImage").val() + '"'; } window.send_to_editor(' [add_to_cart '+type+'="'+prod+'" '+style+' ' +showPrice+' '+buttonImage+' ' +quantity+' ' +text+ ' ' +ajax+ ' ] '); } function shortcode(code){ window.send_to_editor(' ['+code+'] '); } function shortcode_wrap(open, close){ window.send_to_editor(' ['+open+"] <br/>[/"+close+'] '); } function preview(){ var productIndex = jQuery("#productNameSelector option:selected").index(); var priceDescription = jQuery("<div/>").html(prodprices[productIndex]).text(); var price = "<p id='priceLabel'>" + priceDescription + "</p>"; if(jQuery("input:radio[name=showPrice]:checked").val()=="no"){ price = ""; } var style = ""; if(jQuery("#productStyle").val()!="") { style = jQuery("#productStyle").val(); } var text = ""; if(jQuery("#buttonText").val()!="") { text = jQuery("#buttonText").val(); } else { text = '<?php _e("Add to Cart", "cart66"); ?> '; } <?php $setting = new Cart66Setting(); $cartImgPath = Cart66Setting::getValue('cart_images_url'); if ($cartImgPath) { if (strpos(strrev($cartImgPath), '/') !== 0) { $cartImgPath .= '/'; } $buttonPath = $cartImgPath . 'add-to-cart.png'; } ?> var button = ''; <?php if ($cartImgPath) { ?> var buttonPath = '<?php echo $buttonPath; ?> '; button = "<img src='"+buttonPath+"' title='"+text+"' alt='<?php _e('Cart66 Add To Cart Button', 'cart66'); ?> '>"; <?php } else { ?> button = "<input type='button' class='Cart66ButtonPrimary' value='"+text+"' />"; <?php } ?> if(jQuery("#buttonImage").val()!=""){ button = "<img src='"+jQuery("#buttonImage").val()+"' title='<?php _e('Add to Cart', 'cart66'); ?> ' alt='<?php _e('Cart66 Add To Cart Button', 'cart66'); ?> '>"; } if(jQuery("input:radio[name=showPrice]:checked").val()=="only"){ button= ""; } var prevBox = "<div style='"+style+"'>"+price+button+"</div>"; jQuery("#buttonPreview").html(prevBox).text(); if(jQuery("#productNameSelector option:selected").hasClass('subscriptionProduct')){ jQuery('.quantity').hide(); } else{ jQuery('.quantity').show(); } } </script> <div id="select_cart66_shortcode" style="display:none;"> <div id="cart66-shortcode-window"> <div id="cart66-shortcode-header"> <ul class="tabs" id="sidemenu"> <li class="s1" id="tab-products"><a class="s1 tab" href="javascript:void(0)"><?php _e('Products', 'cart66'); ?> </a></li> <li class="s2" id="tab-shortcodes"><a class="s2 tab" href="javascript:void(0)"><?php _e('Shortcodes', 'cart66'); ?> </a></li> </ul> </div> <div class="loading"> <h2 class="center"><?php _e('loading...', 'cart66'); ?> </h2> </div> <div class="s1 panes"> <h3><?php _e("Insert A Product", "cart66"); ?> </h3> <ul> <li> <label for="productNameSelector"><?php _e('Your products'); ?> :</label> <select id="productNameSelector" name="productName"><?php echo $options; ?> </select> </li> <li class="quantity"> <label for="quantityOptions" ><?php _e('Quantity'); ?> :</label> <input type='radio' id="quantityOptions" name="quantityOptions" value='user' checked> <?php _e('User Defined', 'cart66'); ?> <input type='radio' id="quantityOptions" name="quantityOptions" value='pre'> <?php _e('Predefined', 'cart66'); ?> <input type='radio' id="quantityOptions" name="quantityOptions" value='off'> <?php _e('Off', 'cart66'); ?> <br /> </li> <li id="defaultQuantityGroup" class="quantity"> <label for="defaultQuantity"><?php _e('Default Quantity', 'cart66'); ?> :</label> <input id="defaultQuantity" name="defaultQuantity" size="2" value="1"> </li> <li> <label for="buttonText"><?php _e('Button Text'); ?> :</label> <input id="buttonText" name="buttonText" size="34"> </li> <li> <label for="productStyle"><?php _e('CSS style'); ?> :</label> <input id="productStyle" name="productStyle" size="34"> </li> <li> <label for="ajaxOptions" ><?php _e('Ajax Add To Cart'); ?> :</label> <?php if (Cart66Setting::getValue('enable_ajax_by_default') && Cart66Setting::getValue('enable_ajax_by_default') == 1) { ?> <input type='radio' id="ajaxOptions" name="ajaxOptions" value='yes' checked> <?php _e('Yes', 'cart66'); ?> <input type='radio' id="ajaxOptions" name="ajaxOptions" value='no'> <?php _e('No', 'cart66'); ?> <?php } else { ?> <input type='radio' id="ajaxOptions" name="ajaxOptions" value='yes'> <?php _e('Yes', 'cart66'); ?> <input type='radio' id="ajaxOptions" name="ajaxOptions" value='no' checked> <?php _e('No', 'cart66'); ?> <?php } ?> </li> <li> <label for="showPrice" style="display: inline-block; width: 120px; text-align: right;"><?php _e('Show price'); ?> :</label> <input type='radio' id="showPrice" name="showPrice" value='yes' checked> <?php _e('Yes', 'cart66'); ?> <input type='radio' id="showPrice" name="showPrice" value='no'> <?php _e('No', 'cart66'); ?> <input type='radio' id="showPrice" name="showPrice" value='only'> <?php _e('Price Only', 'cart66'); ?> </li> <li> <label for="buttonImage" ><?php _e('Button path'); ?> :</label> <input id="buttonImage" name="buttonImage" size="34"> </li> <li> <label for="buttonImage" ><?php _e('Preview'); ?> :</label> <div class="" id="buttonPreview"></div> </li> <li> </li> </ul> </div> <?php $shortcodes_system = array('express' => __('Listens for PayPal Express callbacks <br/>Belongs on system page store/express', 'cart66'), 'ipn' => __('PayPal Instant Payment Notification <br/>Belongs on system page store/ipn', 'cart66'), 'receipt' => __('Shows the customer\'s receipt after a successful sale <br/>Belongs on system page store/receipt', 'cart66')); $shortcodes = array('add_to_cart item=""' => __('Create add to cart button', 'cart66'), 'cart' => __('Show the shopping cart', 'cart66'), 'cart mode="read"' => __('Show the shopping cart in read-only mode', 'cart66'), 'checkout_mijireh' => __('Mijireh Checkout Accept Credit Cards - PCI Compliant', 'cart66'), 'checkout_stripe' => __('Stripe Checkout form', 'cart66'), 'checkout_2checkout' => __('2Checkout checkout form', 'cart66'), 'checkout_manual' => __('Checkout form that does not process credit cards', 'cart66'), 'checkout_paypal' => __('PayPal Website Payments Standard checkout button', 'cart66'), 'checkout_paypal_express' => __('PayPal Express checkout button', 'cart66'), 'clear_cart' => __('Clear the contents of the shopping cart', 'cart66'), 'shopping_cart' => __('Show the Cart66 sidebar widget', 'cart66'), 'post_sale' => __('Display content one time immediately after a sale', 'cart66'), 'cart66_affiliate' => __('Add order information to an affiliate URL that can be used inside the post_sale shortcode. The only attribute is "display"', 'cart66')); if (CART66_PRO) { $shortcodes_pro = array('account_info' => __('Show link to manage subscription account information', 'cart66'), 'account_login' => __('Account login form', 'cart66'), 'account_logout' => __('Logs user out of account', 'cart66'), 'account_logout_link' => __('Show link to log out of account', 'cart66'), 'account_expiration' => __('Show a member when their account expires', 'cart66'), 'cancel_paypal_subscription' => __('Link to cancel PayPal subscription', 'cart66'), 'checkout_payleap' => __('PayLeap checkout form', 'cart66'), 'checkout_authorizenet' => __('Authorize.net (or AIM compatible gateway) checkout form', 'cart66'), 'checkout_eway' => __('Eway checkout form', 'cart66'), 'checkout_mwarrior' => __('Merchant Warrior checkout form', 'cart66'), 'checkout_paypal_pro' => __('PayPal Pro checkout form', 'cart66'), 'terms_of_service' => __('Show the terms of service agreement', 'cart66'), 'subscription_feature_level' => __('Show the name of the subscription feature level for the currently logged in user', 'cart66'), 'subscription_name' => __('Show the name of the subscription for the currently logged in user', 'cart66'), 'zendesk_login' => __('Listens for remote login calls from Zendesk', 'cart66'), 'hide_from' => __('Hide content from members without the listed feature levels - opposite of [show_to]', 'cart66'), 'show_to' => __('Show content only to members with the listed feature levels - opposite of [hide_from]', 'cart66'), 'email_opt_out' => __('Allow Cart66 members to opt out of receiving notifications about the status of their account.', 'cart66')); $shortcodes = array_merge($shortcodes, $shortcodes_pro); $shortcodes_system['spreedly_listener'] = __('Listens for spreedly account changes <br/>Belongs on system page store/spreedly', 'cart66'); } ksort($shortcodes); ?> <div class="s2 panes"> <h3><?php _e("Insert A System Shortcode", "cart66"); ?> </h3> <table id="shortCodeList" cellpadding="0"> <tr> <td colspan="2"><strong><?php _e('Shortcode Quick Reference', 'cart66'); ?> </strong></td> </tr> <?php foreach ($shortcodes as $shortcode => $description) { ?> <tr> <td><div class="shortcode" <?php if ($shortcode == 'hide_from' || $shortcode == 'show_to' || $shortcode == 'post_sale') { ?> onclick="shortcode_wrap('<?php echo $shortcode; ?> <?php echo $shortcode == 'show_to' || $shortcode == 'hide_from' ? 'level=""' : ''; ?> ', '<?php echo $shortcode; ?> ');" <?php } else { ?> onclick="shortcode('<?php echo $shortcode; ?> ');" <?php } ?> ><a title="Insert [<?php echo $shortcode; ?> ]">[<?php echo $shortcode == 'show_to' || $shortcode == 'hide_from' ? "{$shortcode} level=""" : "{$shortcode}"; ?> ]</a></div></td> <td><?php echo $description; ?> </td> </tr> <?php } ?> </table> <br/> <table id="systemShortCodeList" cellpadding="0"> <tr> <td colspan="2"><strong><?php _e('System Shortcodes', 'cart66'); ?> </strong></td> </tr> <?php foreach ($shortcodes_system as $shortcode => $description) { ?> <tr> <td><div class="shortcode" <?php if ($shortcode == 'hide_from' || $shortcode == 'show_to' || $shortcode == 'post_sale') { ?> onclick="shortcode_wrap('<?php echo $shortcode; ?> <?php echo $shortcode == 'show_to' || $shortcode == 'hide_from' ? 'level=""' : ''; ?> ', '<?php echo $shortcode; ?> ');" <?php } else { ?> onclick="shortcode('<?php echo $shortcode; ?> ');" <?php } ?> ><a title="Insert [<?php echo $shortcode; ?> ]">[<?php echo $shortcode == 'show_to' || $shortcode == 'hide_from' ? "{$shortcode} level=""" : "{$shortcode}"; ?> ]</a></div></td> <td><?php echo $description; ?> </td> </tr> <?php } ?> </table> </div> <div> <div class="buttons"> <input type="button" class="button-secondary" value="<?php _e("Cancel", "cart66"); ?> " onclick="tb_remove();" /> <input id="insertProductButton" type="button" class="button-primary" value="<?php _e("Insert Shortcode", "cart66"); ?> " onclick="insertProductCode();"/> </div> </div> </div> </div> <script type="text/javascript"> (function($){ function adjustHeights() { hWindow = $('#TB_window').height(); wWindow = $('#TB_window').width(); $('#TB_ajaxContent').height(hWindow - 45); $('#TB_ajaxContent').width(wWindow - 30); } $(window).resize(function() { $('#TB_ajaxContent').css('height','auto'); adjustHeights(); }); $(document).ready(function() { preview(); $("input").change(function(){preview();}); $("input").click(function(){preview();}); $("#productNameSelector").change(function(){ preview(); }) adjustHeights(); $("#Cart66ThickBox").click(function(){ adjustHeights(); }) $("input:radio[name=quantityOptions]").change(function(){ if($("input:radio[name=quantityOptions]:checked").val()=="off"){ $("#defaultQuantityGroup").fadeOut(600); } else{ $("#defaultQuantityGroup").fadeIn(600); } }) // setting the tabs in the sidebar hide and show, setting the current tab $('div.panes').hide(); $('div.s1').show(); $('div.loading').hide(); $('#insertProductButton').show(); $('div#cart66-shortcode-header ul.tabs li.s1 a').addClass('current'); // SIDEBAR TABS $('div#cart66-shortcode-header ul li a').click(function(){ adjustHeights(); var thisClass = this.className.slice(0,2); $('div.panes').hide(); $('div.' + thisClass).fadeIn(300); $('div#cart66-shortcode-header ul.tabs li a').removeClass('current'); $('div#cart66-shortcode-header ul.tabs li a.' + thisClass).addClass('current'); if($('.current').hasClass('s1')){ $('#insertProductButton').fadeIn(300); } else{ $('#insertProductButton').fadeOut(300); } }); }); })(jQuery); </script> <?php }
$products = $product->getModels("where id>0", "order by name"); if (count($products)) { $i = 0; foreach ($products as $p) { if ($p->itemNumber == "") { $id = $p->id; $type = 'id'; $description = ""; } else { $id = $p->itemNumber; $type = 'item'; $description = '(# ' . $p->itemNumber . ')'; } $types[] = htmlspecialchars($type); if (CART66_PRO && $p->isPayPalSubscription()) { $sub = new Cart66PayPalSubscription($p->id); $subPrice = strip_tags($sub->getPriceDescription($sub->offerTrial > 0, '(trial)')); $prices[] = htmlspecialchars($subPrice); Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] subscription price in dialog: {$subPrice}"); } else { $prices[] = htmlspecialchars(strip_tags($p->getPriceDescription())); } $options .= '<option value="' . $id . '">' . $p->name . ' ' . $description . '</option>'; $i++; } } else { $options .= '<option value="">No products</option>'; } $prodTypes = implode("\",\"", $types); $prodPrices = implode("\",\"", $prices); ?>