/** * Setup the module for runtime * * Auto-loads settings for the module and setups defaults * * @since 1.1 * * @return void **/ function __construct () { global $Ecart; $this->session = $Ecart->Shopping->session; $this->Order = &EcartOrder(); $this->module = get_class($this); $this->settings = $Ecart->Settings->get($this->module); if (!isset($this->settings['label']) && $this->cards) $this->settings['label'] = __("Credit Card","Ecart"); $this->baseop = $Ecart->Settings->get('base_operations'); $this->precision = $this->baseop['currency']['format']['precision']; $this->_loadcards(); if ($this->myorder()) $this->actions(); }
/** * CartTax constructor * * @since 1.1 * * @return void **/ function __construct () { global $Ecart; $this->Order = &EcartOrder(); $base = $Ecart->Settings->get('base_operations'); $this->format = $base['currency']['format']; $this->vat = $base['vat']; $this->enabled = ($Ecart->Settings->get('taxes') == "on"); $this->rates = $Ecart->Settings->get('taxrates'); $this->shipping = ($Ecart->Settings->get('tax_shipping') == "on"); }
/** * Displays the appropriate account page template * * Replaces the [account] shortcode on the Account page with * the processed template contents. * * @since 1.1 * * @param array $attrs Shortcode attributes * @return string The cart template content **/ function account_page ($menuonly=false) { global $wp; $Order =& EcartOrder(); $Customer =& $Order->Customer; if (isset($Customer->login) && $Customer->login) do_action('ecart_account_management'); ob_start(); if (isset($wp->query_vars['ecart_download'])) include(ECART_TEMPLATES."/errors.php"); elseif ($Customer->login) include(ECART_TEMPLATES."/account.php"); else include(ECART_TEMPLATES."/login.php"); $content = ob_get_contents(); ob_end_clean(); return apply_filters('ecart_account_template',$content); }
/** * Handles product file download requests * * @since 1.1 * * @return void **/ function download () { global $Ecart; $download = $this->request['ecart_download']; $Purchase = false; $Purchased = false; if (defined('WP_ADMIN')) { $forbidden = false; $Download = new ProductDownload($download); } else { $Order = &EcartOrder(); $Download = new ProductDownload(); $Download->loadby_dkey($download); $Purchased = $Download->purchased(); $Purchase = new Purchase($Purchased->purchase); $name = $Purchased->name.(!empty($Purchased->optionlabel)?' ('.$Purchased->optionlabel.')':''); $forbidden = false; // Purchase Completion check if ($Purchase->txnstatus != "CHARGED" && !ECART_PREPAYMENT_DOWNLOADS) { new EcartError(sprintf(__('"%s" cannot be downloaded because payment has not been received yet.','Ecart'),$name),'ecart_download_limit'); $forbidden = true; } // Account restriction checks if ($this->Settings->get('account_system') != "none" && (!$Order->Customer->login || $Order->Customer->id != $Purchase->customer)) { new EcartError(__('You must login to download purchases.','Ecart'),'ecart_download_limit'); ecart_redirect(ecarturl(false,'account')); } // Download limit checking if ($this->Settings->get('download_limit') // Has download credits available && $Purchased->downloads+1 > $this->Settings->get('download_limit')) { new EcartError(sprintf(__('"%s" is no longer available for download because the download limit has been reached.','Ecart'),$name),'ecart_download_limit'); $forbidden = true; } // Download expiration checking if ($this->Settings->get('download_timelimit') // Within the timelimit && $Purchased->created+$this->Settings->get('download_timelimit') < mktime() ) { new EcartError(sprintf(__('"%s" is no longer available for download because it has expired.','Ecart'),$name),'ecart_download_limit'); $forbidden = true; } // IP restriction checks if ($this->Settings->get('download_restriction') == "ip" && !empty($Purchase->ip) && $Purchase->ip != $_SERVER['REMOTE_ADDR']) { new EcartError(sprintf(__('"%s" cannot be downloaded because your computer could not be verified as the system the file was purchased from.','Ecart'),$name),'ecart_download_limit'); $forbidden = true; } do_action_ref_array('ecart_download_request',array(&$Purchased)); } if ($forbidden) { ecart_redirect(ecarturl(false,'account')); } if ($Download->download()) { if ($Purchased !== false) { $Purchased->downloads++; $Purchased->save(); do_action_ref_array('ecart_download_success',array(&$Purchased)); } exit(); } }
/** * Identify the applicable column rate from the Order shipping information * * @since 1.1 * * @param array $rate The shipping rate to be used * @return string The column index name **/ function ratecolumn ($rate) { $Order = &EcartOrder(); $Shipping = &$Order->Shipping; if ($Shipping->country == $this->base['country']) { // Use country/domestic region if (isset($rate[$this->base['country']])) $column = $this->base['country']; // Use the country rate else $column = $Shipping->postarea(); // Try to get domestic regional rate } else if (isset($rate[$Shipping->region])) { // Global region rate $column = $Shipping->region; } else $column = 'Worldwide'; return $column; }
function shipping_costs () { if (!isset($_GET['method'])) return; $Order =& EcartOrder(); if ($_GET['method'] == $Order->Shipping->method) return; $Order->Shipping->method = $_GET['method']; $Order->Cart->retotal = true; $Order->Cart->totals(); echo json_encode($Order->Cart->Totals); exit(); }