コード例 #1
0
 /**
  * Send email receipt and copies thereof.
  * Return true if all the emails that were supposed to be sent got sent.
  * Note that just because the email was sent does not mean the recipient received it.
  * All sorts of things can go awry after the email leaves the server before it is in the
  * recipient's inbox. 
  * 
  * @param int $orderId
  * @return bool
  */
 public function sendEmailReceipts()
 {
     $isSent = false;
     $msg = $this->getEmailReceiptMessage($this->_order);
     $to = $this->_order->email;
     $subject = Cart66Setting::getValue('receipt_subject');
     $headers = 'From: ' . Cart66Setting::getValue('receipt_from_name') . ' <' . Cart66Setting::getValue('receipt_from_address') . '>' . "\r\n\\";
     $msgIntro = Cart66Setting::getValue('receipt_intro');
     if ($this->_order) {
         $isSent = $this->mail($to, $subject, $msg, $headers);
         if (!$isSent) {
             Cart66Common::log("Mail not sent to: {$to}");
         }
         $others = Cart66Setting::getValue('receipt_copy');
         if ($others) {
             $list = explode(',', $others);
             $msg = "THIS IS A COPY OF THE RECEIPT\n\n{$msg}";
             foreach ($list as $e) {
                 $e = trim($e);
                 $isSent = $this->mail($e, $subject, $msg, $headers);
                 if (!$isSent) {
                     Cart66Common::log("Mail not sent to: {$e}");
                 } else {
                     Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Receipt also mailed to: {$e}");
                 }
             }
         }
     }
     return $isSent;
 }
コード例 #2
0
 public function setSelected($value)
 {
     if ($value) {
         $this->_data['isSelected'] = true;
         Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Setting this live rate to selected: " . $this->_data['service']);
     } else {
         $this->_data['isSelected'] = false;
     }
 }
コード例 #3
0
 /**
  * Delete all methods for the given carrier if the carrier code is not in the given array
  */
 public function pruneCarrierMethods($carrier, array $codes)
 {
     $codes = array_map(array($this->_db, 'escape'), $codes);
     Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Codes array map: " . print_r($codes, true));
     $codes = implode("','", $codes);
     $shippingMethods = $this->_tableName;
     // $sql = "DELETE from $shippingMethods where carrier='$carrier' and code NOT IN ($codes)";
     $sql = "DELETE from {$shippingMethods} where carrier=%s and code NOT IN ('{$codes}')";
     $sql = $this->_db->prepare($sql, $carrier);
     Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Pruning shipping methods: {$sql}");
     $this->_db->query($sql);
 }
コード例 #4
0
 public function saveEmailLog($email_data, $email_type, $copy, $status)
 {
     if (Cart66Setting::getValue('enable_email_log') == 1) {
         global $wpdb;
         $date = date("Y-m-d H:i:s", Cart66Common::localTs());
         if (is_array($email_data['msg'])) {
             $email_data['msg'] = $email_data['msg']['text/plain'] . '\\n\\n' . $email_data['msg']['text/html'];
         }
         $data = array('send_date' => $date, 'from_email' => $email_data['from_email'], 'from_name' => $email_data['from_name'], 'to_email' => $email_data['to_email'], 'to_name' => $email_data['to_name'], 'headers' => $email_data['head']['headers'], 'subject' => $email_data['subject'], 'body' => $email_data['msg'], 'attachments' => $email_data['attachments'], 'order_id' => $email_data['order_id'], 'email_type' => $email_type, 'copy' => $copy, 'status' => $status);
         $logTable = Cart66Common::getTableName('email_log');
         $wpdb->insert($logTable, $data);
         $emailLogId = $wpdb->insert_id;
         Cart66Common::log("Saved email log ({$emailLogId}): " . $data['status'] . "\nSQL: " . $wpdb->last_query . ' ' . Cart66Common::localTs());
     }
 }
コード例 #5
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;
 }
コード例 #6
0
 public static function exportOrders($startDate, $endDate)
 {
     global $wpdb;
     $start = date('Y-m-d 00:00:00', strtotime($startDate));
     $end = date('Y-m-d 00:00:00', strtotime($endDate . ' + 1 day'));
     $orders = Cart66Common::getTableName('orders');
     $items = Cart66Common::getTableName('order_items');
     $orderHeaders = array('id' => __('Order ID', 'cart66'), 'trans_id' => __('Order Number', 'cart66'), 'ordered_on' => __('Date', 'cart66'), 'bill_first_name' => __('Billing First Name', 'cart66'), 'bill_last_name' => __('Billing Last Name', 'cart66'), 'bill_address' => __('Billing Address', 'cart66'), 'bill_address2' => __('Billing Address 2', 'cart66'), 'bill_city' => __('Billing City', 'cart66'), 'bill_state' => __('Billing State', 'cart66'), 'bill_country' => __('Billing Country', 'cart66'), 'bill_zip' => __('Billing Zip Code', 'cart66'), 'ship_first_name' => __('Shipping First Name', 'cart66'), 'ship_last_name' => __('Shipping Last Name', 'cart66'), 'ship_address' => __('Shipping Address', 'cart66'), 'ship_address2' => __('Shipping Address 2', 'cart66'), 'ship_city' => __('Shipping City', 'cart66'), 'ship_state' => __('Shipping State', 'cart66'), 'ship_country' => __('Shipping Country', 'cart66'), 'ship_zip' => __('Shipping Zip Code', 'cart66'), 'phone' => __('Phone', 'cart66'), 'email' => __('Email', 'cart66'), 'coupon' => __('Coupon', 'cart66'), 'discount_amount' => __('Discount Amount', 'cart66'), 'shipping' => __('Shipping Cost', 'cart66'), 'subtotal' => __('Subtotal', 'cart66'), 'tax' => __('Tax', 'cart66'), 'total' => __('Total', 'cart66'), 'ip' => __('IP Address', 'cart66'), 'shipping_method' => __('Delivery Method', 'cart66'), 'status' => __('Order Status', 'cart66'));
     $orderColHeaders = implode(',', $orderHeaders);
     $orderColSql = implode(',', array_keys($orderHeaders));
     $out = $orderColHeaders . ",Form Data,Item Number,Description,Quantity,Product Price,Form ID\n";
     $sql = "SELECT {$orderColSql} from {$orders} where ordered_on >= %s AND ordered_on < %s AND status != %s order by ordered_on";
     $sql = $wpdb->prepare($sql, $start, $end, 'checkout_pending');
     Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] SQL: {$sql}");
     $selectedOrders = $wpdb->get_results($sql, ARRAY_A);
     foreach ($selectedOrders as $o) {
         $itemRowPrefix = '"' . $o['id'] . '","' . $o['trans_id'] . '",' . str_repeat(',', count($o) - 3);
         $orderId = $o['id'];
         $sql = "SELECT form_entry_ids, item_number, description, quantity, product_price FROM {$items} where order_id = {$orderId}";
         Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Item query: {$sql}");
         $selectedItems = $wpdb->get_results($sql, ARRAY_A);
         $out .= '"' . implode('","', $o) . '"';
         $printItemRowPrefix = false;
         if (!empty($selectedItems)) {
             foreach ($selectedItems as $i) {
                 if ($printItemRowPrefix) {
                     $out .= $itemRowPrefix;
                 }
                 if ($i['form_entry_ids'] && CART66_PRO) {
                     $i['form_id'] = $i['form_entry_ids'];
                     $GReader = new Cart66GravityReader();
                     $i['form_entry_ids'] = $GReader->displayGravityForm($i['form_entry_ids'], true);
                     $i['form_entry_ids'] = str_replace("\"", "''", $i['form_entry_ids']);
                 }
                 $i['description'] = str_replace(",", " -", $i['description']);
                 $out .= ',"' . implode('","', $i) . '"';
                 $out .= "\n";
                 $printItemRowPrefix = true;
             }
         } else {
             $out .= "\n";
         }
     }
     Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Report\n{$out}");
     return $out;
 }
コード例 #7
0
 public function checkFulfillmentSettings($orderId)
 {
     $order = new Cart66Order($orderId);
     $data = array();
     foreach ($order->getItems() as $item) {
         $data[] = $item->product_id;
     }
     $orderFulfillment = new Cart66OrderFulfillment();
     $orderF = $orderFulfillment->getModels();
     $notify = new Cart66AdvancedNotifications($orderId);
     foreach ($orderF as $of) {
         $products = array_filter(explode(',', $of->products));
         if (array_intersect($data, $products) || empty($products)) {
             Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] THEY INTERSECT!");
             $notify->sendOrderFulfillmentEmails($of->id);
         }
     }
 }
コード例 #8
0
ファイル: Cart66Log.php プロジェクト: rbredow/allyzabbacart
 /**
  * Attempt to create a log file in the plugins/cart66 directory
  * Returns the path to the log file. If the file could not be created a Cart66Exception is thrown.
  *
  * @return string
  * @throws Cart66Exception on failure to create log file
  */
 public static function createLogFile()
 {
     $logDirPath = CART66_PATH;
     $logFilePath = self::getLogFilePath();
     if (file_exists($logDirPath)) {
         if (is_writable($logDirPath)) {
             @fclose(fopen($logFilePath, 'a'));
             if (!is_writable($logFilePath)) {
                 Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Unable to create log file. {$logFilePath}");
                 throw new Cart66Exception("Unable to create log file. {$logFilePath}");
             }
         } else {
             throw new Cart66Exception("Log file directory is not writable. {$logDirPath}");
         }
     } else {
         throw new Cart66Exception("Log file directory does not exist. {$logDirPath}");
     }
     return $logFilePath;
 }
コード例 #9
0
 public static function getRemoteRequestParams()
 {
     $params = false;
     $setting = new Cart66Setting();
     $orderNumber = Cart66Setting::getValue('order_number');
     if (!$orderNumber) {
         Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Order number not available");
     }
     $version = Cart66Setting::getValue('version');
     if (!$version) {
         Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Version number not available");
     }
     if ($orderNumber && $version) {
         global $wpdb;
         $versionName = 'pro';
         $params = sprintf("task=getLatestVersion&pn=Cart66&key=%s&v=%s&vnm=%s&wp=%s&php=%s&mysql=%s&ws=%s", urlencode($orderNumber), urlencode($version), urlencode($versionName), urlencode(get_bloginfo("version")), urlencode(phpversion()), urlencode($wpdb->db_version()), urlencode(get_bloginfo("url")));
     }
     return $params;
 }
コード例 #10
0
 public static function curlRequest($url, $method = "get", $data = null)
 {
     Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] curl request info: {$url}\nMethod: {$method}\nData: {$data}");
     $ch = curl_init(self::$baseUri . $url);
     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
     curl_setopt($ch, CURLOPT_MAXREDIRS, 0);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_USERPWD, self::$apiToken . ":X");
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
     curl_setopt($ch, CURLOPT_TIMEOUT, 8);
     curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: text/xml", "Accept: text/xml"));
     switch ($method) {
         case "post":
             if ($data) {
                 curl_setopt($ch, CURLOPT_POST, true);
                 curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
             } else {
                 curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
             }
             break;
         case "delete":
             curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
             break;
         case "put":
             $fh = fopen("php://memory", "rw");
             fwrite($fh, $data);
             rewind($fh);
             curl_setopt($ch, CURLOPT_INFILE, $fh);
             curl_setopt($ch, CURLOPT_INFILESIZE, strlen($data));
             curl_setopt($ch, CURLOPT_PUT, true);
             curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: text/xml", "Accept: text/xml", "Expect:"));
             break;
         default:
             curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
             break;
     }
     $result = new StdClass();
     $result->response = curl_exec($ch);
     $result->code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
     return $result;
 }
コード例 #11
0
 /**
  * Log the PayPal recurring payment. 
  * 
  * The $data array paramter is a URL decoded version of the IPN post data.
  *   - Log the data in the pp_recurring_posts table
  *   - Update the account_subscriptions table with the new active_until date
  */
 public function log(array $ipnData)
 {
     $isLogged = false;
     $subscription = new Cart66AccountSubscription();
     if ($subscription->loadByPayPalBillingProfileId($ipnData['recurring_payment_id'])) {
         $data = array('account_id' => $subscription->accountId, 'recurring_payment_id' => $ipnData['recurring_payment_id'], 'mc_gross' => $ipnData['mc_gross'], 'txn_id' => $ipnData['txn_id'], 'product_name' => $ipnData['product_name'], 'first_name' => $ipnData['first_name'], 'last_name' => $ipnData['last_name'], 'payer_email' => $ipnData['payer_email'], 'ipn' => serialize($ipnData), 'next_payment_date' => $ipnData['next_payment_date'], 'time_created' => date('Y-m-d H:i:s', strtotime($ipnData['time_created'])));
         $this->setData($data);
         $id = $this->save();
         if ($id > 0) {
             $isLogged = true;
             Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Recurring payment logged with ID: {$id}");
             $subscription->extendActiveUntil($ipnData['next_payment_date']);
         } else {
             Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Failed to log recurring payment. " . print_r($data, true));
         }
     } else {
         Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Unable to log recurring payment because the paypal billing profile id is unknown: " . $ipnData['recurring_payment_id']);
     }
     return $isLogged;
 }
コード例 #12
0
ファイル: Cart66Admin.php プロジェクト: rbredow/allyzabbacart
 public static function productsPage()
 {
     $data = array();
     $subscriptions = array('0' => 'None');
     if (class_exists('SpreedlySubscription')) {
         $spreedlySubscriptions = SpreedlySubscription::getSubscriptions();
         foreach ($spreedlySubscriptions as $s) {
             $subs[(int) $s->id] = (string) $s->name;
         }
         if (count($subs)) {
             asort($subs);
             foreach ($subs as $id => $name) {
                 $subscriptions[$id] = $name;
             }
         }
     } else {
         Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Not loading Spreedly data because Spreedly class has not been loaded");
     }
     $data['subscriptions'] = $subscriptions;
     $view = Cart66Common::getView('admin/products.php', $data);
     echo $view;
 }
コード例 #13
0
 function doSale()
 {
     $sale = false;
     if ($this->params['amount'] > 0) {
         // Execute the HTTPS post via CURL
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_URL, $this->gateway_url);
         curl_setopt($ch, CURLOPT_HEADER, 0);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
         curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
         curl_setopt($ch, CURLOPT_TIMEOUT, 80);
         curl_setopt($ch, CURLOPT_USERPWD, $this->_apiKey);
         curl_setopt($ch, CURLOPT_POST, 1);
         curl_setopt($ch, CURLOPT_POSTFIELDS, self::encodeParams($this->params));
         // Do not worry about checking for SSL certs
         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
         curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
         $this->response_string = json_decode(curl_exec($ch));
         Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] response: " . print_r($this->response_string, true));
         //$errno = curl_errno($ch);
         curl_close($ch);
         if (isset($this->response_string->error)) {
             $this->response['Response Reason Text'] = $this->response_string->error->message;
             $this->response['Response Reason Code'] = $this->response_string->error->type;
         } else {
             if (isset($this->response_string->paid) && $this->response_string->paid == 1) {
                 $sale = $this->response_string->id;
             } else {
                 $this->response['Response Reason Text'] = 'No Transaction ID Provided';
             }
         }
     } else {
         // Process free orders without sending to the Stripe gateway
         $this->response_string->id = 'MT-' . Cart66Common::getRandString();
         $sale = $this->response_string->id;
     }
     return $sale;
 }
コード例 #14
0
 /**
  * Return an array of enabled spreedly subscriptions
  * 
  * @return array
  */
 public static function getSubscriptions()
 {
     if (empty(self::$_subscriptionPlans)) {
         $result = SpreedlyCommon::curlRequest("/subscription_plans.xml", "get");
         if ($result->code == '200') {
             $subscriptions = array();
             $plans = new SimpleXmlElement($result->response);
             foreach ($plans as $plan) {
                 $subscription = new SpreedlySubscription();
                 $subscription->setData($plan);
                 /// Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Spreedly subscription enabled: " . $subscription->enabled);
                 if ('true' == (string) $subscription->enabled) {
                     $subscriptions[] = $subscription;
                 }
             }
             self::$_subscriptionPlans = $subscriptions;
         } else {
             Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Spreedly Subscription: Unable to retrieve remote list of subscriptions ");
             //throw new SpreedlyException('Spreedly Subscription: Unable to retrieve remote list of subscriptions', 66003);
         }
     }
     return self::$_subscriptionPlans;
 }
コード例 #15
0
 protected function _buildNvpStr()
 {
     $nvp = false;
     $dataSources = array('_apiData', '_requestFields', '_ecUrls', '_creditCardData', '_payerInfo', '_payerName', '_payerAddress', '_paymentDetails', '_payerShipToAddress');
     $params = array();
     foreach ($dataSources as $source) {
         if (is_array($this->{$source}) && count($this->{$source}) > 0) {
             foreach ($this->{$source} as $key => $value) {
                 // Only add values that contain a value
                 if (isset($value) && strlen($value) > 0) {
                     $value = urlencode($value);
                     $params[] = "{$key}={$value}";
                 }
             }
         }
     }
     // Add information about individual items
     if (is_array($this->_items) && count($this->_items) > 0) {
         $counter = 0;
         // Look for subscriptions first. PayPal feels like this is important.
         foreach ($this->_items as $itemInfo) {
             if (isset($itemInfo['BILLINGAGREEMENTDESCRIPTION'])) {
                 $params[] = 'L_BILLINGAGREEMENTDESCRIPTION' . $counter . '=' . urlencode($itemInfo['BILLINGAGREEMENTDESCRIPTION']);
                 $params[] = 'L_BILLINGTYPE' . $counter . '=' . 'RecurringPayments';
             }
         }
         // Look for non-subscription products
         foreach ($this->_items as $itemInfo) {
             if (!isset($itemInfo['BILLINGAGREEMENTDESCRIPTION'])) {
                 $params[] = 'L_NAME' . $counter . '=' . urlencode($itemInfo['NAME']);
                 $params[] = 'L_AMT' . $counter . '=' . urlencode(number_format($itemInfo['AMT'], 2, '.', ''));
                 $params[] = 'L_NUMBER' . $counter . '=' . urlencode($itemInfo['NUMBER']);
                 $params[] = 'L_QTY' . $counter . '=' . urlencode($itemInfo['QTY']);
                 $counter++;
             }
         }
     } else {
         Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Not adding information about individual products because this items array is empty: " . print_r($this->_items, true));
     }
     $nvp = implode('&', $params);
     return $nvp;
 }
コード例 #16
0
                  <label class="long"><?php 
    _e('Quantity field', 'cart66');
    ?>
:</label>
                  <select name="product[gravity_form_qty_id]" id="product-gravity_form_qty_id">
                    <option value='0'><?php 
    _e('None', 'cart66');
    ?>
</option>
                    <?php 
    try {
        $gr = new Cart66GravityReader($product->gravityFormId);
        $fields = $gr->getStandardFields();
        foreach ($fields as $id => $label) {
            $id = str_replace("'", "", $id);
            Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Gravity Form Fields :: {$id} => {$label}");
            $selected = $product->gravityFormQtyId == $id ? 'selected="selected"' : '';
            echo "<option value='{$id}' {$selected}>{$label}</option>\n";
        }
    } catch (Cart66Exception $e) {
        $exception = Cart66Exception::exceptionMessages($e->getCode(), $e->getMessage());
        $gravityError = Cart66Common::getView('views/error-messages.php', $exception);
    }
    ?>
                  </select>
                  <?php 
    echo isset($gravityError) ? $gravityError : '';
    ?>
                  <span class="label_desc"><?php 
    _e('Use one of the Gravity Form fields as the quantity for your product.', 'cart66');
    ?>
コード例 #17
0
 public function generateUnsubscribeLink($accountId)
 {
     $url = false;
     if ($unsubscribeLink = get_page_by_path('store/unsubscribe')) {
         $account = new Cart66Account();
         $account->load($accountId);
         $url = get_permalink($unsubscribeLink->ID) . '?cart66-task=opt_out&e=' . urlencode(base64_encode($account->email)) . '&t=' . Cart66ProCommon::generateEmailToken($account->id);
         Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] {$url}");
     }
     return $url;
 }
コード例 #18
0
 // calculate taxes on all sales
 $tax = 0;
 $isTaxed = $taxRate->loadByState('All Sales');
 if ($isTaxed) {
     $taxable = Cart66Session::get('Cart66Cart')->getTaxableAmount($taxRate->tax_shipping);
     $tax = number_format($taxable * ($taxRate->rate / 100), 2, '.', '');
     if ($tax == 0) {
         $tax = Cart66Session::get('Cart66Cart')->getTax('All Sales');
     }
     if ($tax > 0) {
         $total = $total + $tax;
     }
 }
 // Set payment information
 $payment = array('AMT' => $total, 'TAXAMT' => $tax, 'CURRENCYCODE' => CURRENCY_CODE, 'ITEMAMT' => $itemTotal, 'SHIPPINGAMT' => $shipping, 'NOTIFYURL' => $ipnUrl);
 Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Setting Payment Details:\n" . print_r($payment, true));
 $pp->setPaymentDetails($payment);
 // Add cart items to PayPal
 $pp->populatePayPalCartItems();
 // Set Express Checkout URLs
 $returnPage = get_page_by_path('store/express');
 $returnUrl = get_permalink($returnPage->ID);
 $cancelPage = get_page_by_path('store/checkout');
 $cancelUrl = get_permalink($cancelPage->ID);
 $localeCode = Cart66Common::getLocaleCode();
 $ecUrls = array('RETURNURL' => $returnUrl, 'CANCELURL' => $cancelUrl, 'LOCALECODE' => $localeCode);
 $pp->setEcUrls($ecUrls);
 $response = $pp->SetExpressCheckout();
 $ack = strtoupper($response['ACK']);
 if ('SUCCESS' == $ack || 'SUCCESSWITHWARNING' == $ack) {
     Cart66Session::set('PayPalProToken', $response['TOKEN']);
コード例 #19
0
 /**
  * Pay a spreedly invoice. The invoice token is required for payment.
  * Returns the paid invoice token.
  * 
  * @param mixed $paymentMethod Either "on-file" or a SpreedlyCreditCard object
  * @param string $invoiceToken 
  * @return string The invoice token that was paid.
  * @throws SpreedlyException on failure
  */
 public function pay($paymentMethod, $invoiceToken = null)
 {
     $payment = array('account-type' => 'on-file');
     if (get_class($paymentMethod) == 'SpreedlyCreditCard') {
         if (!$paymentMethod->validate()) {
             $errorDetails = print_r($paymentMethod->getErrors(), true);
             throw new SpreedlyException('Spreedly Payment: Invalid credit card data trying to be used to pay a spreedly invoice: ' . $errorDetails, 66001);
         }
         $cardData = $paymentMethod->getCardData();
         $payment = array('account-type' => 'credit-card', 'credit-card' => $cardData);
     }
     // Set invoice token if provided
     if (isset($invoiceToken)) {
         $this->setToken($invoiceToken);
     }
     // Make sure there is an invoice token before trying to process the payment
     if (empty($this->_invoiceToken)) {
         throw new SpreedlyException('Spreedly Payment: Trying to pay spreedly invoice without a valid invoice token', 66002);
     }
     $xml = Cart66Common::arrayToXml($payment, 'payment');
     $result = SpreedlyCommon::curlRequest('/invoices/' . $this->_invoiceToken . '/pay.xml', "put", $xml);
     $responseCode = $result->code;
     if (!empty($responseCode)) {
         if ($responseCode != 200) {
             Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Spreedly Invoice Payment: Failed to pay invoice. \n          Code: " . $responseCode . "\nResponse: " . $result->response . "\n Payment XML:\n{$xml}");
             $errorResponse = $result->response;
             throw new SpreedlyException("Spreedly Payment: Failed to pay spreedly invoice. \n\n{$errorResponse}", $responseCode);
         }
         try {
             $invoice = new SimpleXMLElement($result->response);
             $this->_invoiceToken = $invoice->token;
         } catch (Exception $e) {
             Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] SpreedlyInvoice pay(): \n          Unable to create SimpleXmlElement from result response: " . $result->response);
         }
     }
 }
コード例 #20
0
 /**
  * All fields are optional - any field that is not provided will not be updated.
  */
 public static function updateRemoteAccount($customerId, $subscriberData)
 {
     $subscriberXml = Cart66Common::arrayToXml($subscriberData, 'subscriber');
     $result = SpreedlyCommon::curlRequest("/subscribers/{$customerId}.xml", "put", $subscriberXml);
     if ($result->code != '200') {
         Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Spreedly Subscriber: Account information could not be updated. " . $result->response . "\nCode: {$result->code}");
         throw new SpreedlyException('Spreedly Subscriber: Account information could not be updated.', $result->code);
     }
 }
コード例 #21
0
 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;
 }
コード例 #22
0
ファイル: shipping.php プロジェクト: rbredow/allyzabbacart
                $m->name = $name;
                $m->carrier = 'capost_intl';
                $m->save();
                $intlCodes[] = $code;
            }
        } else {
            $intlCodes[] = -1;
        }
        $method->pruneCarrierMethods('capost_intl', $intlCodes);
        $tab = 5;
    } elseif ($_POST['cart66-action'] == 'enable live rates') {
        Cart66Setting::setValue('use_live_rates', 1);
    } elseif ($_POST['cart66-action'] == 'disable live rates') {
        Cart66Setting::setValue('use_live_rates', '');
    } elseif ($_POST['cart66-action'] == 'save rate tweak') {
        Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Saving a rate tweak");
        $factor = Cart66Common::postVal('rate_tweak_factor');
        if (is_numeric($factor)) {
            Cart66Setting::setValue('rate_tweak_factor', $factor);
            Cart66Setting::setValue('rate_tweak_type', Cart66Common::postVal('rate_tweak_type'));
        } else {
            Cart66Setting::setValue('rate_tweak_factor', '');
            Cart66Setting::setValue('rate_tweak_type', '');
        }
        $tab = 7;
    }
} elseif (isset($_GET['task']) && $_GET['task'] == 'edit' && isset($_GET['id']) && $_GET['id'] > 0) {
    $id = Cart66Common::getVal('id');
    $rule->load($id);
} elseif (isset($_GET['task']) && $_GET['task'] == 'edit_method' && isset($_GET['id']) && $_GET['id'] > 0) {
    $id = Cart66Common::getVal('id');
コード例 #23
0
<?php

$url = trim($url);
$saleAmt = $order->subtotal - $order->discount_amount;
$saleAmt = number_format($saleAmt, 2, '.', '');
$url = str_replace('idev_saleamt=XXX', 'idev_saleamt=' . $saleAmt, $url);
$url = str_replace('idev_ordernum=XXX', 'idev_ordernum=' . $order->trans_id, $url);
$ip = $_SERVER['REMOTE_ADDR'];
if ($order->ip != '') {
    $ip = $order->ip;
}
Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] order ip: {$ip}");
$url .= '&ip_address=' . $ip;
$promotionCode = Cart66Session::get('Cart66PromotionCode');
if (Cart66Setting::getValue('idev_coupon_codes') && $promotionCode) {
    $url .= '&coupon_code=' . $promotionCode;
}
Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Commission notification sent to: {$url}");
Cart66Common::curl($url);
コード例 #24
0
 /**
  * Manage the status of the recurring payments profile identified by the profileId
  * Action may be: Cancel, Suspend, or Reactivate.
  *   Cancel - Only profiles in Active or Suspended state can be canceled.
  *   Suspend - Only profiles in Active state can be suspended.
  *   Reactivate - Only profiles in a suspended state can be reactivated.
  */
 public function ManageRecurringPaymentsProfileStatus($profileId, $action, $note)
 {
     $this->_requestFields = array('METHOD' => 'ManageRecurringPaymentsProfileStatus', 'PROFILEID' => $profileId, 'ACTION' => $action, 'NOTE' => $note);
     $nvp = $this->_buildNvpStr();
     Cart66Common::log("Manage recurring payments profile request NVP: " . str_replace('&', "\n", $nvp));
     $result = $this->_decodeNvp($this->_sendRequest($this->_apiEndPoint, $nvp));
     Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Manage recurring payments profile response: " . print_r($result, true));
     return $result;
 }
コード例 #25
0
                }
            }
        }
        ?>

  <?php 
        if ($order->hasAccount() == -1) {
            ?>
    <?php 
            if (!Cart66Common::isLoggedIn()) {
                ?>
      <h2>Please Create Your Account</h2>
    
      <?php 
                if (isset($data['errors'])) {
                    Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Account creation errors: " . print_r($data, true));
                    echo Cart66Common::showErrors($data['errors'], 'Your account could not be created.');
                    echo Cart66Common::getJqErrorScript($data['jqErrors']);
                }
                ?>
    
      <?php 
                $account = $data['account'];
                if (!is_object($account)) {
                    $account = new Cart66Account();
                }
                ?>
      <form action="" method='post' id="account_form" class="phorm2">
        <input type="hidden" name="ouid" value="<?php 
                echo $order->ouid;
                ?>
コード例 #26
0
ファイル: checkout.php プロジェクト: rbredow/allyzabbacart
// Set initial country codes for billing and shipping addresses
$billingCountryCode = isset($b['country']) && !empty($b['country']) ? $b['country'] : Cart66Common::getHomeCountryCode();
$shippingCountryCode = isset($s['country']) && !empty($s['country']) ? $s['country'] : Cart66Common::getHomeCountryCode();
// Include the HTML markup for the checkout form
$checkoutFormFile = CART66_PATH . '/views/checkout-form.php';
if ($gatewayName == 'Cart66Mijireh') {
    $checkoutFormFile = CART66_PATH . '/views/mijireh/shipping_address.php';
} elseif ($gatewayName == 'Cart662Checkout') {
    $checkoutFormFile = CART66_PATH . '/views/2checkout.php';
} else {
    $userViewFile = get_stylesheet_directory() . '/cart66-templates/views/checkout-form.php';
    if (file_exists($userViewFile) && filesize($userViewFile) > 10 && CART66_PRO && Cart66Common::isRegistered()) {
        $checkoutFormFile = $userViewFile;
    }
}
Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Using Checkout Form File :: {$checkoutFormFile}");
ob_start();
include $checkoutFormFile;
$checkoutFormFileContents = ob_get_contents();
ob_end_clean();
echo Cart66Common::minifyMarkup($checkoutFormFileContents);
// Include the client side javascript validation
$same_as_billing = false;
if ($_SERVER['REQUEST_METHOD'] == 'GET' && Cart66Setting::getValue('sameAsBillingOff') != 1) {
    $same_as_billing = true;
} elseif (isset($_POST['sameAsBilling']) && $_POST['sameAsBilling'] == '1') {
    $same_as_billing = true;
}
$shipping_address_display = !$same_as_billing || $gatewayName == 'Cart66Mijireh' || $gatewayName == 'Cart662Checkout' ? 'block' : 'none';
$billing_country = '';
if (isset($b['country']) && !empty($b['country'])) {
コード例 #27
0
ファイル: Cart66Order.php プロジェクト: rbredow/allyzabbacart
 public function dailyPrunePendingPayPalOrders()
 {
     Cart66Setting::setValue('daily_prune_pending_orders_last_checked', Cart66Common::localTs());
     $o = new Cart66Order();
     $dayStart = date('Y-m-d 00:00:00', strtotime('48 hours ago', Cart66Common::localTs()));
     $dayEnd = date('Y-m-d 00:00:00', strtotime('24 hours ago', Cart66Common::localTs()));
     $orders = $o->getOrderRows("WHERE status in ('paypal_pending','checkout_pending') AND ordered_on >= '{$dayStart}' AND ordered_on < '{$dayEnd}'");
     foreach ($orders as $order) {
         Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] yes, i am to delete an order or more: " . $order->id);
         $o->load($order->id);
         $o->deleteMe(true, true);
     }
 }
コード例 #28
0
ファイル: Cart66Usps.php プロジェクト: rbredow/allyzabbacart
 /**
  * Given an XML string return an array where the keys are the services and the values are the rates.
  * 
  * @param string $xml An xml string
  * @return array
  */
 public function _parseIntlResult($xml)
 {
     if ($xml = simplexml_load_string($xml)) {
         $this->clearRates();
         if ($xml->Package->Service) {
             foreach ($xml->Package->Service as $service) {
                 $name = (string) $service->SvcDescription;
                 $rate = (double) $service->Postage;
                 $name = str_replace('&lt;sup&gt;&#174;&lt;/sup&gt;', '', $name);
                 $name = str_replace('&lt;sup&gt;&#8482;&lt;/sup&gt;', '', $name);
                 $name = str_replace('*', '', $name);
                 $this->addRate($name, $rate);
                 Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] USPS: Adding international rate ===> {$name} -- {$rate}");
             }
         } else {
             Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Unknown Failure: " . print_r($xml, true));
         }
     } else {
         Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] USPS Intl xml parsing failure. Unable to load XML string: {$xml}");
     }
 }
コード例 #29
0
 public function emailShortcodes($attrs)
 {
     $output = '';
     if ($attrs['source'] == 'receipt' || $attrs['source'] == 'fulfillment' || $attrs['source'] == 'status' || $attrs['source'] == 'followup') {
         $order = new Cart66Order($attrs['id']);
         $data = array('bill_first_name', 'bill_last_name', 'bill_address', 'bill_address2', 'bill_city', 'bill_state', 'bill_country', 'bill_zip', 'ship_first_name', 'ship_last_name', 'ship_address', 'ship_address2', 'ship_city', 'ship_state', 'ship_country', 'ship_zip', 'phone', 'email', 'coupon', 'discount_amount', 'trans_id', 'shipping', 'subtotal', 'tax', 'total', 'non_subscription_total', 'custom_field', 'ordered_on', 'status', 'ip', 'products', 'fulfillment_products', 'receipt', 'receipt_link', 'ouid', 'shipping_method', 'account_id', 'tracking_number', 'feature_level', 'subscription_plan_name', 'active_until', 'billing_interval', 'username');
         if (in_array($attrs['att'], $data)) {
             switch ($attrs['att']) {
                 case 'bill_first_name':
                     // Intentional falling through
                 // Intentional falling through
                 case 'bill_last_name':
                 case 'ship_first_name':
                 case 'ship_last_name':
                     $output = ucfirst(strtolower($order->{$attrs}['att']));
                     break;
                 case 'bill_address':
                     if ($order->bill_address2 != '') {
                         $output = $order->{$attrs}['att'] . '<br />' . $order->bill_address2;
                     } else {
                         $output = $order->{$attrs}['att'];
                     }
                     break;
                 case 'ship_address':
                     if ($order->ship_address2 != '') {
                         $output = $order->{$attrs}['att'] . '<br />' . $order->ship_address2;
                     } else {
                         $output = $order->{$attrs}['att'];
                     }
                     break;
                 case 'products':
                     $output = Cart66Common::getView('/pro/views/emails/email-products.php', array('order' => $order, 'type' => $attrs['type'], 'code' => 'products'));
                     break;
                 case 'fulfillment_products':
                     $output = Cart66Common::getView('/pro/views/emails/email-products.php', array('order' => $order, 'type' => $attrs['type'], 'code' => 'fulfillment_products', 'variable' => $attrs['variable']));
                     break;
                 case 'receipt':
                     $output = Cart66Common::getView('/pro/views/emails/email-receipt.php', array('order' => $order, 'type' => $attrs['type']));
                     break;
                 case 'phone':
                     $output = Cart66Common::formatPhone($order->{$attrs}['att']);
                     break;
                 case 'total':
                     $output = Cart66Common::currency($order->{$attrs}['att'], false);
                     break;
                 case 'tax':
                     $output = Cart66Common::currency($order->{$attrs}['att'], false);
                     break;
                 case 'receipt_link':
                     $receiptPage = get_page_by_path('store/receipt');
                     $link = get_permalink($receiptPage->ID);
                     if (strstr($link, "?")) {
                         $link .= '&ouid=';
                     } else {
                         $link .= '?ouid=';
                     }
                     $output = $link . $order->ouid;
                     break;
                 case 'feature_level':
                     // Intentionally falling through
                 // Intentionally falling through
                 case 'active_until':
                 case 'subscription_plan_name':
                 case 'active_until':
                 case 'active_until':
                 case 'billing_interval':
                     if ($order->account_id) {
                         $sub = new Cart66AccountSubscription($order->account_id);
                         $output = $sub->{$attrs}['att'];
                     } else {
                         $output = "None";
                     }
                     break;
                 case 'username':
                     if ($order->account_id) {
                         $sub = new Cart66AccountSubscription($order->account_id);
                         $account = new Cart66Account();
                         $account->load($sub->account_id);
                         //Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Loaded account: " . print_r($account, true) );
                         $output = $account->{$attrs}['att'];
                     } else {
                         $output = "None";
                     }
                     break;
                 default:
                     $output = $order->{$attrs}['att'];
             }
         } elseif (substr($attrs['att'], 0, 8) == 'tracking') {
             $output = Cart66AdvancedNotifications::updateTracking($order, $attrs);
         } elseif (substr($attrs['att'], 0, 5) == 'date:') {
             $output = Cart66AdvancedNotifications::updateDate($attrs);
         } elseif (substr($attrs['att'], 0, 12) == 'date_ordered') {
             $output = Cart66AdvancedNotifications::updateDateOrdered($order, $attrs);
         }
         $shipping_options = array('ship_first_name', 'ship_last_name', 'ship_address', 'ship_address2', 'ship_city', 'ship_state', 'ship_country', 'ship_zip');
         if (in_array($attrs['att'], $shipping_options) && $order->shipping_method == 'None') {
             $output = '';
         }
     } elseif ($attrs['source'] == 'reminder') {
         $sub = new Cart66AccountSubscription($attrs['id']);
         $account = new Cart66Account();
         $account->load($sub->account_id);
         $data = array('billing_first_name', 'billing_last_name', 'feature_level', 'subscription_plan_name', 'active_until', 'billing_interval', 'username', 'opt_out_link');
         if (in_array($attrs['att'], $data)) {
             switch ($attrs['att']) {
                 case 'billing_first_name':
                     // Intentional falling through
                 // Intentional falling through
                 case 'billing_last_name':
                     $output = ucfirst(strtolower($sub->{$attrs}['att']));
                     break;
                 case 'active_until':
                     $output = date(get_option('date_format'), strtotime($sub->{$attrs}['att']));
                     break;
                 case 'username':
                     $output = $account->{$attrs}['att'];
                     break;
                 case 'opt_out_link':
                     $output = Cart66ProCommon::generateUnsubscribeLink($account->id);
                     break;
                 default:
                     $output = $sub->{$attrs}['att'];
             }
         }
     }
     Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] output: {$output}");
     return $output;
 }
コード例 #30
0
 public function save()
 {
     foreach ($this->_data as $key => $value) {
         if (is_scalar($value)) {
             $this->_data[$key] = stripslashes($value);
         }
     }
     Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] " . get_class($this) . " Saving Data: " . print_r($this->_data, true));
     return $this->_data['id'] >= 1 ? $this->_update() : $this->_insert();
 }