Beispiel #1
0
	function __construct () {
		global $Ecart;
		parent::__construct();

		$this->Settings = &$Ecart->Settings;
		$this->Catalog = &$Ecart->Catalog;
		$this->Category = &$Ecart->Category;
		$this->Product = &$Ecart->Product;

		$pages = $this->Settings->get('pages');
		if (!empty($pages)) $this->pages = $pages;

		Ecart_buyObject::store('search',$this->search);
		Ecart_buyObject::store('browsing',$this->browsing);
		Ecart_buyObject::store('breadcrumb',$this->breadcrumb);
		Ecart_buyObject::store('referrer',$this->referrer);

		add_action('wp', array(&$this, 'pageid'));
		add_action('wp', array(&$this, 'security'));
		add_action('wp', array(&$this, 'cart'));
		add_action('wp', array(&$this, 'catalog'));
		add_action('wp', array(&$this, 'shortcodes'));
		add_action('wp', array(&$this, 'behaviors'));

		add_filter('the_title', array(&$this,'pagetitle'), 10, 2);

		// Ecart product text filters
		add_filter('ecart_product_name','convert_chars');
		add_filter('ecart_product_summary','convert_chars');

		add_filter('ecart_product_description', 'wptexturize');
		add_filter('ecart_product_description', 'convert_chars');
		add_filter('ecart_product_description', 'wpautop');
		add_filter('ecart_product_description', 'do_shortcode', 11); // AFTER wpautop()

		add_filter('ecart_product_spec', 'wptexturize');
		add_filter('ecart_product_spec', 'convert_chars');
		add_filter('ecart_product_spec', 'do_shortcode', 11); // AFTER wpautop()


		add_filter('ecart_order_lookup','ecartdiv');
		add_filter('ecart_order_confirmation','ecartdiv');
		add_filter('ecart_errors_page','ecartdiv');
		add_filter('ecart_cart_template','ecartdiv');
		add_filter('ecart_checkout_page','ecartdiv');
		add_filter('ecart_account_template','ecartdiv');
		add_filter('ecart_order_receipt','ecartdiv');
		add_filter('ecart_account_manager','ecartdiv');
		add_filter('ecart_account_vieworder','ecartdiv');

		add_filter('aioseop_canonical_url', array(&$this,'canonurls'));
		add_action('wp_enqueue_scripts', 'ecart_dependencies');

		$this->smartcategories();
		$this->searching();
		$this->account();
	}
Beispiel #2
0
	/**
	 * Setup error system and PHP error capture
	 *
	 * @since 1.0
	 *
	 * @return void
	 **/
	function __construct ($level = ECART_ALL_ERR) {
		Ecart_buyObject::store('errors',$this->errors);

		if (defined('WP_DEBUG') && WP_DEBUG) $this->reporting = ECART_DEBUG_ERR;
		if ($level > $this->reporting) $this->reporting = $level;

		$this->notifications = new CallbackSubscription();

		$types = E_ALL ^ E_NOTICE;
		if (defined('WP_DEBUG') && WP_DEBUG) $types = E_ALL;
		// Handle PHP errors
		if ($this->reporting >= ECART_PHP_ERR)
			set_error_handler(array($this,'phperror'),$types);
	}
Beispiel #3
0
	/**
	 * Initializes the Ecart runtime environment
	 * 
	 * @since 1.0
	 *
	 * @return void
	 **/
	function init () {

		$this->Errors = new EcartErrors($this->Settings->get('error_logging'));
		$this->Order = Ecart_buyObject::__new('Order');
		$this->Promotions = Ecart_buyObject::__new('CartPromotions');
		$this->Gateways = new GatewayModules();
		$this->Shipping = new ShippingModules();
		$this->Storage = new StorageEngines();
		$this->SmartCategories = array();

		$this->ErrorLog = new EcartErrorLogging($this->Settings->get('error_logging'));
		$this->ErrorNotify = new EcartErrorNotification($this->Settings->get('merchant_email'),
									$this->Settings->get('error_notifications'));

		if (!$this->Shopping->handlers) new EcartError(__('The Cart session handlers could not be initialized because the session was started by the active theme or an active plugin before Ecart could establish its session handlers. The cart will not function.','Ecart'),'ecart_cart_handlers',ECART_ADMIN_ERR);
		if (ECART_DEBUG && $this->Shopping->handlers) new EcartError('Session handlers initialized successfully.','ecart_cart_handlers',ECART_DEBUG_ERR);
		if (ECART_DEBUG) new EcartError('Session started.','ecart_session_debug',ECART_DEBUG_ERR);

		global $pagenow;

		new Login();
		do_action('ecart_init');
	}
Beispiel #4
0
	function updates () {
		global $Ecart;

		// Cancel processing if this is not a PayPal Website Payments Standard/Express Checkout IPN
		if (isset($_POST['txn_type']) && $_POST['txn_type'] != "cart") return false;

		$target = false;
		if (isset($_POST['txn_id']) && !isset($_POST['parent_txn_id']))
			$target = $_POST['txn_id'];
		elseif (!empty($_POST['parent_txn_id'])) $target = $_POST['parent_txn_id'];

		// No transaction target: invalid IPN, silently ignore the message
		if (!$target) return;

		// Validate the order notification
		if ($this->verifyipn() != "VERIFIED") {
			new EcartError(sprintf(__('An unverifiable order update notification was received from PayPal for transaction: %s. Possible fraudulent notification!  The order will not be updated.  IPN message: %s','Ecart'),$target,_object_r($_POST)),'paypal_txn_verification',ECART_TRXN_ERR);
			return false;
		}

		$Purchase = new Purchase($target,'txnid');

		// Purchase record exists, update it
		if ($Purchase->txnid == $target && !empty($Purchase->id)) {
			if ($Purchase->gateway != $this->name) return; // Not a PPS order, don't touch it
			$txnstatus = isset($this->status[$_POST['payment_status']])?
				$this->status[$_POST['payment_status']]:$_POST['payment_status'];

			$Purchase->txnstatus = $txnstatus;
			$Purchase->save();

			$Ecart->Purchase = &$Purchase;
			$Ecart->Order->purchase = $Purchase->id;

			do_action('ecart_order_notifications');
			die('PayPal IPN update processed.');
		}

		if (!isset($_POST['custom'])) {
			new EcartError(sprintf(__('No reference to the pending order was available in the PayPal IPN message. Purchase creation failed for transaction %s.'),$target),'paypalstandard_process_neworder',ECART_TRXN_ERR);
			die('PayPal IPN failed.');
		}

		$Ecart->Order->unhook();
		$Ecart->resession($_POST['custom']);
		$Ecart->Order = Ecart_buyObject::__new('Order',$Ecart->Order);
		$this->actions();

		$Shopping = &$Ecart->Shopping;
		// Couldn't load the session data
		if ($Shopping->session != $_POST['custom'])
			return new EcartError("Session could not be loaded: {$_POST['custom']}",false,ECART_DEBUG_ERR);
		else new EcartError("PayPal successfully loaded session: {$_POST['custom']}",false,ECART_DEBUG_ERR);

		$this->ipnupdates();

		do_action('ecart_process_order'); // New order
		die('PayPal IPN processed.');
	}
Beispiel #5
0
	/**
	* merchant_calc()
	* Callback function for merchant calculated shipping and taxes
	* taxes calculations unimplemented
	* returns false when it responds, as acknowledgement of merchant calculations is unnecessary
	* */
	function merchant_calc ($XML) {
		global $Ecart;

		if ($XML->content('shipping') == 'false') return true;  // ack

		$sessionid = $XML->content('shopping-session');
		$Ecart->resession($sessionid);
		$Ecart->Order = Ecart_buyObject::__new('Order',$Ecart->Order);
		$Ecart->Order->listeners();
		$Shopping = &$Ecart->Shopping;
		$Order = &$Ecart->Order;

		// Get new address information on order
		$shipto = $XML->tag('anonymous-address');

		$Order->Shipping->city = $shipto->content('city'); //['city']['CONTENT']
		$Order->Shipping->state = $shipto->content('region'); //['region']['CONTENT']
		$Order->Shipping->country = $shipto->content('country-code'); //['country-code']['CONTENT']
		$Order->Shipping->postcode = $shipto->content('postal-code'); //['postal-code']['CONTENT']

		// Calculate shipping options
		$Shipping = new CartShipping();
		$Shipping->calculate();
		$options = $Shipping->options();
		if (empty($options)) return true; // acknowledge, but don't respond

		$methods = $XML->attr('method','name');

		$address_id = $XML->attr('anonymous-address','id');
		$_ = array('<?xml version="1.0" encoding="UTF-8"?>');
		$_[] = "<merchant-calculation-results xmlns=\"http://checkout.google.com/schema/2\">";
		$_[] = "<results>";
		foreach ($options as $option) {
			if (in_array($option->name, $methods)) {
				$_[] = '<result shipping-name="'.$option->name.'" address-id="'.$address_id.'">';
				$_[] = '<shipping-rate currency="'.$this->settings['currency'].'">'.number_format($option->amount,$this->precision,'.','').'</shipping-rate>';
				$_[] = '<shippable>true</shippable>';
				$_[] = '</result>';
			}
		}
		$_[] = "</results>";
		$_[] = "</merchant-calculation-results>";

		if(ECART_DEBUG) new EcartError(join("\n",$_),'google-merchant-calculation-results',ECART_DEBUG_ERR);
		$this->response($_);
		return false; //no ack
	}