本文整理汇总了PHP中Cart66Common::log方法的典型用法代码示例。如果您正苦于以下问题:PHP Cart66Common::log方法的具体用法?PHP Cart66Common::log怎么用?PHP Cart66Common::log使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cart66Common
的用法示例。
在下文中一共展示了Cart66Common::log方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sendEmailReceipts
/**
* 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: setSelected
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: pruneCarrierMethods
/**
* 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: saveEmailLog
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: getCartButton
/**
* 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: exportOrders
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: checkFulfillmentSettings
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: createLogFile
/**
* 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: getRemoteRequestParams
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: curlRequest
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: log
/**
* 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: productsPage
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: doSale
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: getSubscriptions
/**
* 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: _buildNvpStr
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;
}