本文整理汇总了PHP中Cart66Setting类的典型用法代码示例。如果您正苦于以下问题:PHP Cart66Setting类的具体用法?PHP Cart66Setting怎么用?PHP Cart66Setting使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Cart66Setting类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dailySubscriptionEmailReminderCheck
public static function dailySubscriptionEmailReminderCheck()
{
Cart66Setting::setValue('daily_subscription_reminders_last_checked', Cart66Common::localTs());
// Function that fires daily to send out subscription reminder emails. This will be triggered once a day at 3 AM.
// If this function fires emails will be sent.
$dayStart = date('Y-m-d 00:00:00', Cart66Common::localTs());
$dayEnd = date('Y-m-d 00:00:00', strtotime('+ 1 day', Cart66Common::localTs()));
$reminder = new Cart66MembershipReminders();
$reminders = $reminder->getModels();
foreach ($reminders as $r) {
if ($r->enable == 1) {
$interval = explode(',', $r->interval);
foreach ($interval as $i) {
$new_interval = trim($i) . ' ' . $r->interval_unit;
$product = new Cart66Product($r->subscription_plan_id);
$start = date('Y-m-d H:i:s', strtotime('+ ' . $new_interval, strtotime($dayStart)));
$end = date('Y-m-d H:i:s', strtotime('+ ' . $new_interval, strtotime($dayEnd)));
$sub = new Cart66AccountSubscription();
$subs = $sub->getModels("where active_until >= '{$start}' AND active_until < '{$end}' AND lifetime != '1' AND product_id = '{$product->id}'");
$log = array();
foreach ($subs as $s) {
if ($r->validateReminderEmails($s->id)) {
$r->sendReminderEmails($s->id);
$log[] = $s->id . ' :: ' . $s->billing_first_name . ' ' . $s->billing_last_name;
}
}
Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Start: {$start} :: End: {$end}");
Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] subscription ids that meet the criteria: " . print_r($log, true));
}
}
}
}
示例2: initCheckout
public function initCheckout($total)
{
$p = $this->getPayment();
$b = $this->getBilling();
Cart66Common::log("Payment info for checkout: " . print_r($p, true));
$expDate = $p['cardExpirationMonth'] . substr($p['cardExpirationYear'], 2);
$this->addField('Description', 'Your shopping cart');
$this->addField('method', 'processCard');
$this->addField('transactionAmount', number_format($total, 2, '.', ''));
$this->addField('transactionCurrency', Cart66Setting::getValue('mwarrior_currency'));
$this->addField('transactionProduct', '12345');
$this->addField('merchantUUID', $this->_apiData['MERCHANTUUID']);
$this->addField('apiKey', $this->_apiData['APIKEY']);
$this->addField('customerName', $b['firstName'] . ' ' . $b['lastName']);
$this->addField('customerCountry', $b['country']);
$this->addField('customerAddress', $b['address']);
$this->addField('customerCity', $b['city']);
$this->addField('customerState', $b['state']);
$this->addField('customerPostCode', $b['zip']);
$this->addField('customerPhone', $p['phone']);
$this->addField('customerEmail', $p['email']);
$this->addField('paymentCardNumber', $p['cardNumber']);
$this->addField('paymentCardExpiry', $expDate);
$this->addField('paymentCardCSC', $p['securityId']);
$this->addField('paymentCardName', $b['firstName'] . ' ' . $b['lastName']);
$this->addField('customerIP', self::getRemoteIP());
$this->addField('hash', self::calculateHash($this->fields));
}
示例3: login
public static function login(Cart66Account $account)
{
$name = $account->firstName . ' ' . $account->lastName;
$email = $account->email;
$externalId = $account->id;
$organization = Cart66Setting::getValue('zendesk_organization');
$key = Cart66Setting::getValue('zendesk_token');
$prefix = Cart66Setting::getValue('zendesk_prefix');
if (Cart66Setting::getValue('zendesk_jwt')) {
$now = time();
$token = array("jti" => md5($now . rand()), "iat" => $now, "name" => $name, "email" => $email);
include_once CART66_PATH . "/pro/models/JWT.php";
$jwt = JWT::encode($token, $key);
// Redirect
header("Location: https://" . $prefix . ".zendesk.com/access/jwt?jwt=" . $jwt);
exit;
} else {
/* Build the message */
$ts = isset($_GET['timestamp']) ? $_GET['timestamp'] : time();
$message = $name . '|' . $email . '|' . $externalId . '|' . $organization . '|||' . $key . '|' . $ts;
$hash = MD5($message);
$remoteAuthUrl = 'http://' . $prefix . '.zendesk.com/access/remoteauth/';
$arguments = array('name' => $name, 'email' => $email, 'external_id' => $externalId, 'organization' => $organization, 'timestamp' => $ts, 'hash' => $hash);
$url = add_query_arg($arguments, $remoteAuthUrl);
header("Location: " . $url);
exit;
}
}
示例4: resendEmailFromLog
public static function resendEmailFromLog($id)
{
$resendEmail = false;
global $wpdb;
$tableName = Cart66Common::getTableName('email_log');
$sql = "SELECT * from {$tableName} where id = {$id}";
$results = $wpdb->get_results($sql);
if ($results) {
foreach ($results as $r) {
$resendEmail = Cart66Notifications::mail($r->to_email, $r->subject, $r->body, $r->headers);
$email = new Cart66EmailLog();
$email_data = array('from_email' => $r->from_email, 'from_name' => $r->from_name, 'to_email' => $r->to_email, 'to_name' => $r->to_name, 'head' => array('headers' => $r->headers), 'subject' => $r->subject, 'msg' => $r->body, 'attachments' => $r->attachments, 'order_id' => $r->order_id);
if (!$resendEmail) {
if (Cart66Setting::getValue('log_resent_emails')) {
$email->saveEmailLog($email_data, $r->email_type, $r->copy, 'RESEND FAILED');
}
} else {
if (Cart66Setting::getValue('log_resent_emails')) {
$email->saveEmailLog($email_data, $r->email_type, $r->copy, 'RESEND SUCCESSFUL');
}
}
}
}
return $resendEmail;
}
示例5: __construct
public function __construct()
{
$setting = new Cart66Setting();
$this->username = Cart66Setting::getValue('capost_username');
$this->password = Cart66Setting::getValue('capost_password');
$this->customer_number = Cart66Setting::getValue('capost_customer_number');
$this->fromZip = Cart66Setting::getValue('capost_ship_from_zip');
$this->credentials = 1;
}
示例6: setPayment
public function setPayment($p)
{
$this->_payment = $p;
$skip = array('email', 'phone', 'custom-field');
$custom_payment_fields = apply_filters('cart66_after_payment_form', '');
if (is_array($custom_payment_fields)) {
foreach ($custom_payment_fields as $key => $payment_field) {
if (!$payment_field['required']) {
$skip[] = $payment_field['slug'];
}
if (isset($payment_field['validator']) && $payment_field['validator'] != '') {
if (function_exists($payment_field['validator'])) {
$skip[] = $payment_field['slug'];
$data_to_validate = isset($p[$payment_field['slug']]) ? $p[$payment_field['slug']] : '';
$validated = call_user_func($payment_field['validator'], $data_to_validate);
if (!$validated['valid']) {
foreach ($validated['errors'] as $key => $error) {
$this->_errors['Payment ' . $payment_field['slug'] . $key] = $error;
$this->_jqErrors[] = 'payment-' . $payment_field['slug'];
}
}
}
}
}
}
foreach ($p as $key => $value) {
if (!in_array($key, $skip)) {
$value = trim($value);
if ($value == '') {
$keyName = ucwords(preg_replace('/([A-Z])/', " \$1", $key));
$this->_errors['Payment ' . $keyName] = __('Payment ', 'cart66') . $keyName . __(' required', 'cart66');
$this->_jqErrors[] = "payment-{$key}";
}
}
}
if ($p['email'] == '') {
$this->_errors['Email address'] = __('Email address is required', 'cart66');
$this->_jqErrors[] = "payment-email";
}
if ($p['phone'] == '') {
$this->_errors['Phone'] = __('Phone number is required', 'cart66');
$this->_jqErrors[] = "payment-phone";
}
if (!Cart66Common::isValidEmail($p['email'])) {
$this->_errors['Email'] = __("Email address is not valid", "cart66");
$this->_jqErrors[] = 'payment-email';
}
if (Cart66Setting::getValue('checkout_custom_field_display') == 'required' && $p['custom-field'] == '') {
$this->_errors['Custom Field'] = Cart66Setting::getValue('checkout_custom_field_error_label') ? Cart66Setting::getValue('checkout_custom_field_error_label') : __('The Special Instructions Field is required', 'cart66');
$this->_jqErrors[] = 'checkout-custom-field-multi';
$this->_jqErrors[] = 'checkout-custom-field-single';
}
}
示例7: initCheckout
public function initCheckout($total)
{
$p = $this->getPayment();
$b = $this->getBilling();
Cart66Common::log("Payment info for checkout: " . print_r($p, true));
// Load gateway url from Cart66 settings
$gatewayUrl = Cart66Setting::getValue('auth_url');
$this->gateway_url = $gatewayUrl;
$b['address2'] = $b['address2'] == "" ? null : $b['address2'];
$cardData = array('number' => $p['cardNumber'], 'exp_month' => $p['cardExpirationMonth'], 'exp_year' => $p['cardExpirationYear'], 'cvc' => $p['securityId'], 'name' => $b['firstName'] . ' ' . $b['lastName'], 'address_line1' => $b['address'], 'address_line2' => $b['address2'], 'address_zip' => $b['zip'], 'address_state' => $b['state'], 'address_country' => $b['country']);
$this->params = array('card' => $cardData, 'amount' => number_format($total, 2, '', ''), 'currency' => Cart66Setting::getValue('stripe_currency_code') ? Cart66Setting::getValue('stripe_currency_code') : strtolower(Cart66Setting::getValue('currency_code')), 'description' => '');
}
示例8: prepareS3Url
public static function prepareS3Url($bucket, $file, $duration = '5 minutes')
{
$awsKeyId = Cart66Setting::getValue('amazons3_id');
$awsSecretKey = Cart66Setting::getValue('amazons3_key');
$file = rawurlencode($file);
$file = str_replace('%2F', '/', $file);
$path = $bucket . '/' . $file;
$expires = strtotime("+ {$duration}", current_time('timestamp', 1));
$stringToSign = self::getStringToSign('GET', $expires, "/{$path}");
$signature = self::encodeSignature($stringToSign, $awsSecretKey);
$url = "http://{$bucket}.s3.amazonaws.com/{$file}";
$url .= '?AWSAccessKeyId=' . $awsKeyId . '&Expires=' . $expires . '&Signature=' . $signature;
return $url;
}
示例9: getAddToCartImagePath
/**
* Return the image path for the add to cart button or false if no path is available
*/
public static function getAddToCartImagePath($attrs)
{
$path = false;
if (isset($attrs['img'])) {
// Look for custom image for this instance of the button
$path = $attrs['img'];
} else {
// Look for common images
$cartImgPath = Cart66Setting::getValue('cart_images_url');
if ($cartImgPath) {
$cartImgPath = Cart66Common::endSlashPath($cartImgPath);
$path = $cartImgPath . 'add-to-cart.png';
}
}
return $path;
}
示例10: 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;
}
示例11: getRate
/**
* Return the monetary value of the shipping rate or false on failure.
*/
public function getRate($PostalCode, $dest_zip, $dest_country_code, $service, $weight, $length = 0, $width = 0, $height = 0)
{
$setting = new Cart66Setting();
$countryCode = array_shift(explode('~', Cart66Setting::getValue('home_country')));
$pickupCode = Cart66Setting::getValue('ups_pickup_code') ? Cart66Setting::getValue('ups_pickup_code') : "03";
$ResidentialAddressIndicator = Cart66Setting::getValue('ups_only_ship_commercial') ? "" : "\n <ResidentialAddressIndicator/>";
if ($this->credentials != 1) {
print 'Please set your credentials with the setCredentials function';
die;
}
$data = "<?xml version=\"1.0\"?> \n <AccessRequest xml:lang=\"en-US\"> \n <AccessLicenseNumber>" . urlencode(trim($this->AccessLicenseNumber)) . "</AccessLicenseNumber> \n <UserId>" . urlencode($this->UserID) . "</UserId> \n <Password>" . urlencode($this->Password) . "</Password> \n </AccessRequest> \n <?xml version=\"1.0\"?> \n <RatingServiceSelectionRequest xml:lang=\"en-US\"> \n <Request> \n <TransactionReference> \n <CustomerContext>Rating and Service</CustomerContext> \n <XpciVersion>1.0001</XpciVersion> \n </TransactionReference> \n <RequestAction>Rate</RequestAction> \n <RequestOption>Rate</RequestOption> \n </Request> \n <PickupType> \n <Code>{$pickupCode}</Code> \n </PickupType> \n <Shipment> \n <Shipper> \n <Address> \n <PostalCode>{$PostalCode}</PostalCode> \n <CountryCode>{$countryCode}</CountryCode> \n </Address> \n <ShipperNumber>{$this->shipperNumber}</ShipperNumber> \n </Shipper> \n <ShipTo> \n <Address> \n <PostalCode>{$dest_zip}</PostalCode> \n <CountryCode>{$dest_country_code}</CountryCode>{$ResidentialAddressIndicator} \n </Address> \n </ShipTo> \n <ShipFrom> \n <Address> \n <PostalCode>{$PostalCode}</PostalCode> \n <CountryCode>{$countryCode}</CountryCode> \n </Address> \n </ShipFrom> \n <Service> \n <Code>{$service}</Code> \n </Service> \n <Package> \n <PackagingType> \n <Code>02</Code> \n </PackagingType> \n <Dimensions> \n <UnitOfMeasurement> \n <Code>{$this->dimensionsUnits}</Code> \n </UnitOfMeasurement> \n <Length>{$length}</Length> \n <Width>{$width}</Width> \n <Height>{$height}</Height> \n </Dimensions> \n <PackageWeight> \n <UnitOfMeasurement> \n <Code>{$this->weightUnits}</Code> \n </UnitOfMeasurement> \n <Weight>{$weight}</Weight> \n </PackageWeight> \n </Package> \n </Shipment> \n </RatingServiceSelectionRequest>";
$ch = curl_init("https://onlinetools.ups.com/ups.app/xml/Rate");
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$result = curl_exec($ch);
$xml = substr($result, strpos($result, '<RatingServiceSelectionResponse'));
Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] UPS XML REQUEST: \n{$data}");
Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] UPS XML RESULT: \n{$xml}");
try {
$xml = new SimpleXmlElement($xml);
} catch (Exception $e) {
Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Cart66 Exception caught when trying to get UPS XML Response: " . $e->getMessage() . " \n");
$rate = false;
}
$responseDescription = $xml->Response->ResponseStatusDescription;
$errorDescription = $xml->Response->Error->ErrorDescription;
// Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Response Description: (Service: $service) $responseDescription $errorDescription");
if ($responseDescription == "Failure") {
$rate = false;
} else {
//$rate = $xml->RatedShipment->RatedPackage->TotalCharges->MonetaryValue;
$rate = $xml->RatedShipment->TotalCharges->MonetaryValue;
}
Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] RATE ===> {$rate}");
return $rate;
}
示例12: getCreditCardTypes
/**
* Return an array of accepted credit card types where the keys are the diplay values and the values are the gateway values
*
* @return array
*/
public function getCreditCardTypes()
{
$cardTypes = array();
$setting = new Cart66Setting();
$cards = Cart66Setting::getValue('auth_card_types');
if ($cards) {
$cards = explode('~', $cards);
if (in_array('mastercard', $cards)) {
$cardTypes['MasterCard'] = 'mastercard';
}
if (in_array('visa', $cards)) {
$cardTypes['Visa'] = 'visa';
}
if (in_array('amex', $cards)) {
$cardTypes['American Express'] = 'amex';
}
if (in_array('discover', $cards)) {
$cardTypes['Discover'] = 'discover';
}
}
return $cardTypes;
}
示例13: SetExpressCheckout
public function SetExpressCheckout()
{
$this->_requestFields = array('METHOD' => 'SetExpressCheckout', 'PAYMENTACTION' => 'Sale');
if (!Cart66Setting::getValue('disable_landing_page')) {
$this->_requestFields['LANDINGPAGE'] = 'Billing';
}
if (Cart66Setting::getValue('express_force_paypal')) {
$this->_requestFields['SOLUTIONTYPE'] = 'Sole';
}
$nvp = $this->_buildNvpStr();
Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Set Express Checkout Request NVP: " . str_replace('&', "\n", $nvp));
$result = $this->_decodeNvp($this->_sendRequest($this->_apiEndPoint, $nvp));
Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] SetExpressCheckout result: " . print_r($result, true));
return $result;
}
示例14: trim
<?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);
示例15: getUpsServices
public static function getUpsServices()
{
$usaServices = array('UPS Next Day Air' => '01', 'UPS Second Day Air' => '02', 'UPS Ground' => '03', 'UPS Worldwide Express' => '07', 'UPS Worldwide Expedited' => '08', 'UPS Standard' => '11', 'UPS Three-Day Select' => '12', 'UPS Next Day Air Early A.M.' => '14', 'UPS Worldwide Express Plus' => '54', 'UPS Second Day Air A.M.' => '59', 'UPS Saver' => '65');
$internationalServices = array('UPS Express' => '01', 'UPS Expedited' => '02', 'UPS Worldwide Express' => '07', 'UPS Worldwide Expedited' => '08', 'UPS Standard' => '11', 'UPS Three-Day Select' => '12', 'UPS Saver' => '13', 'UPS Express Early A.M.' => '14', 'UPS Worldwide Express Plus' => '54', 'UPS Saver' => '65');
$homeCountryCode = 'US';
$setting = new Cart66Setting();
$home = Cart66Setting::getValue('home_country');
if ($home) {
list($homeCountryCode, $name) = explode('~', $home);
}
$services = $homeCountryCode == 'US' ? $usaServices : $internationalServices;
return $services;
}