protected function checkGEOIP() { if (Config::inst()->get("EcommerceCountry", "visitor_country_provider") == "EcommerceCountry_VisitorCountryProvider" && !class_exists("Geoip")) { user_error("\r\n\t\t\t\tYou need to install Geoip module that has a method Geoip::visitor_country, returning the country code associated with the user's IP address.\r\n\t\t\t\tAlternatively you can set the following config EcommerceCountry.visitor_country_provider to something like MyGEOipProvider.\r\n\t\t\t\tYou then create a class MyGEOipProvider with a method getCountry().", E_USER_NOTICE); } elseif (Director::isLive() && !EcommerceCountry::get_country_from_ip()) { user_error("\r\n\t\t\t\tPlease make sure that '" . $this->Config()->get("visitor_country_provider") . "' (visitor_country_provider) is working on your server (see the GEOIP module for details).", E_USER_NOTICE); } }
public function getCountry() { $countryCodes = array("Billing" => "", "Shipping" => ""); if ($this->BillingAddressID) { $billingAddress = BillingAddress::get()->byID($this->BillingAddressID); if ($billingAddress) { if ($billingAddress->Country) { $countryCodes["Billing"] = $billingAddress->Country; } } } if ($this->ShippingAddressID && $this->UseShippingAddress) { $shippingAddress = BillingAddress::get()->byID($this->ShippingAddressID); if ($shippingAddress) { if ($shippingAddress->ShippingCountry) { $countryCodes["Shipping"] = $shippingAddress->ShippingCountry; } } } if (EcommerceConfig::get("OrderAddress", "use_shipping_address_for_main_region_and_country") && $countryCodes["Shipping"] || !$countryCodes["Billing"] && $countryCodes["Shipping"]) { return $countryCodes["Shipping"]; } elseif ($countryCodes["Billing"]) { return $countryCodes["Billing"]; } else { return EcommerceCountry::get_country_from_ip(); } }
/** * Produces a debug of the shopping cart. */ public function debug() { if (Director::isDev() || Permission::check("ADMIN")) { debug::show($this->currentOrder()); echo "<hr /><hr /><hr /><hr /><hr /><hr /><h1>Country</h1>"; echo "GEOIP Country: " . EcommerceCountry::get_country_from_ip() . "<br />"; echo "Calculated Country Country: " . EcommerceCountry::get_country() . "<br />"; echo "<blockquote><blockquote><blockquote><blockquote>"; echo "<hr /><hr /><hr /><hr /><hr /><hr /><h1>Items</h1>"; $items = $this->currentOrder()->Items(); echo $items->sql(); echo "<hr />"; if ($items->count()) { foreach ($items as $item) { Debug::show($item); } } else { echo "<p>there are no items for this order</p>"; } echo "<hr /><hr /><hr /><hr /><hr /><hr /><h1>Modifiers</h1>"; $modifiers = $this->currentOrder()->Modifiers(); if ($modifiers->count()) { foreach ($modifiers as $modifier) { Debug::show($modifier); } } else { echo "<p>there are no modifiers for this order</p>"; } echo "<hr /><hr /><hr /><hr /><hr /><hr /><h1>Addresses</h1>"; $billingAddress = $this->currentOrder()->BillingAddress(); if ($billingAddress && $billingAddress->exists()) { Debug::show($billingAddress); } else { echo "<p>there is no billing address for this order</p>"; } $shippingAddress = $this->currentOrder()->ShippingAddress(); if ($shippingAddress && $shippingAddress->exists()) { Debug::show($shippingAddress); } else { echo "<p>there is no shipping address for this order</p>"; } $currencyUsed = $this->currentOrder()->CurrencyUsed(); if ($currencyUsed && $currencyUsed->exists()) { echo "<hr /><hr /><hr /><hr /><hr /><hr /><h1>Currency</h1>"; Debug::show($currencyUsed); } $cancelledBy = $this->currentOrder()->CancelledBy(); if ($cancelledBy && $cancelledBy->exists()) { echo "<hr /><hr /><hr /><hr /><hr /><hr /><h1>Cancelled By</h1>"; Debug::show($cancelledBy); } $logs = $this->currentOrder()->OrderStatusLogs(); if ($logs && $logs->count()) { echo "<hr /><hr /><hr /><hr /><hr /><hr /><h1>Logs</h1>"; foreach ($logs as $log) { Debug::show($log); } } $payments = $this->currentOrder()->Payments(); if ($payments && $payments->count()) { echo "<hr /><hr /><hr /><hr /><hr /><hr /><h1>Payments</h1>"; foreach ($payments as $payment) { Debug::show($payment); } } $emails = $this->currentOrder()->Emails(); if ($emails && $emails->count()) { echo "<hr /><hr /><hr /><hr /><hr /><hr /><h1>Emails</h1>"; foreach ($emails as $email) { Debug::show($email); } } echo "</blockquote></blockquote></blockquote></blockquote>"; } else { echo "Please log in as admin first"; } }