/** * Constructor */ protected function __construct() { global $section, $action; parent::__construct(__FILE__); // register backend if (class_exists('backend')) { $backend = backend::getInstance(); $import_menu = $backend->getMenu('shop_import'); if (!is_null($import_menu)) { $import_menu->addChild(null, new backend_MenuItem($this->getLanguageConstant('menu_import_items'), url_GetFromFilePath($this->path . 'images/import.svg'), window_Open('shop_import_items', 350, $this->getLanguageConstant('title_import_items'), true, true, backend_UrlMake($this->name, 'import')), 6)); $import_menu->addChild(null, new backend_MenuItem($this->getLanguageConstant('menu_import_english'), url_GetFromFilePath($this->path . 'images/import.svg'), window_Open('shop_import_items', 350, $this->getLanguageConstant('title_import_items'), true, true, backend_UrlMake($this->name, 'import_english')), 6)); } } // register delivery method and create menu items if (ModuleHandler::is_loaded('backend') && ModuleHandler::is_loaded('shop')) { require_once 'units/method.php'; require_once 'units/pickup_method.php'; Paid_DeliveryMethod::getInstance($this); Pickup_DeliveryMethod::getInstance($this); } if (ModuleHandler::is_loaded('head_tag') && $section == 'shop' && $action == 'checkout') { $head_tag = head_tag::getInstance(); $head_tag->addTag('script', array('src' => url_GetFromFilePath($this->path . 'include/pikaday.js'), 'type' => 'text/javascript')); $head_tag->addTag('link', array('href' => url_GetFromFilePath($this->path . 'include/pikaday.css'), 'rel' => 'stylesheet', 'type' => 'text/css')); $head_tag->addTag('link', array('href' => url_GetFromFilePath($this->path . 'include/checkout.css'), 'rel' => 'stylesheet', 'type' => 'text/css')); } if (ModuleHandler::is_loaded('backend') && ModuleHandler::is_loaded('head_tag') && $section == 'backend') { $head_tag = head_tag::getInstance(); $head_tag->addTag('script', array('src' => url_GetFromFilePath($this->path . 'include/backend.js'), 'type' => 'text/javascript')); } // connect transaction handling event Events::connect('shop', 'transaction-completed', 'on_transaction_completed', $this); }
/** * Constructor */ protected function __construct($parent) { global $section; parent::__construct($parent); // register payment method $this->name = 'paypal_express'; $this->registerPaymentMethod(); // connect signal handler Events::connect('shop', 'before-checkout', 'beforeCheckout', $this); }
/** * Constructor */ protected function __construct() { global $section; parent::__construct(__FILE__); // register backend if (class_exists('backend')) { $backend = backend::getInstance(); Events::connect('backend', 'user-create', 'handleUserCreate', $this); Events::connect('backend', 'user-delete', 'handleUserDelete', $this); } // connect to shop events if (class_exists('shop')) { $shop = shop::getInstance(); Events::connect('shop', 'transaction-completed', 'handleTransactionCompleted', $this); Events::connect('shop', 'recurring-payment', 'handleRecurringPayment', $this); Events::connect('shop', 'recurring-payment-suspended', 'handleRecurringPaymentSuspended', $this); } }
/** * Constructor * * @return backend */ protected function __construct() { global $section, $language; parent::__construct(__FILE__); // create events Events::register('backend', 'user-create'); Events::register('backend', 'user-change'); Events::register('backend', 'user-delete'); Events::register('backend', 'user-password-change'); // load CSS and JScript if (class_exists('head_tag') && $section == 'backend') { $head_tag = head_tag::getInstance(); $collection = collection::getInstance(); $collection->includeScript(collection::JQUERY); $collection->includeScript(collection::JQUERY_EVENT_DRAG); $collection->includeScript(collection::WINDOW_SYSTEM); if ($_SESSION['logged']) { $collection->includeScript(collection::JQUERY_EXTENSIONS); $collection->includeScript(collection::NOTEBOOK); $collection->includeScript(collection::SHOWDOWN); $collection->includeScript(collection::TOOLBAR); } $head_tag->addTag('link', array('href' => url_GetFromFilePath($this->path . 'include/backend.css'), 'rel' => 'stylesheet', 'type' => 'text/css')); $head_tag->addTag('script', array('src' => url_GetFromFilePath($this->path . 'include/backend.js'), 'type' => 'text/javascript')); } // add admin level menus if ($section == 'backend') { $system_menu = new backend_MenuItem($this->getLanguageConstant('menu_system'), url_GetFromFilePath($this->path . 'images/icons/16/system.svg'), 'javascript:void(0);', $level = 1); $system_menu->addChild(null, new backend_MenuItem($this->getLanguageConstant('menu_modules'), url_GetFromFilePath($this->path . 'images/icons/16/modules.svg'), window_Open('system_modules', 610, $this->getLanguageConstant('title_modules'), true, false, backend_UrlMake($this->name, 'modules')), $level = 10)); $system_menu->addChild(null, new backend_MenuItem($this->getLanguageConstant('menu_users'), url_GetFromFilePath($this->path . 'images/icons/16/users.svg'), window_Open('system_users', 690, $this->getLanguageConstant('title_users_manager'), true, false, backend_UrlMake($this->name, 'users')), $level = 10)); $system_menu->addSeparator(10); $system_menu->addChild(null, new backend_MenuItem($this->getLanguageConstant('menu_change_password'), url_GetFromFilePath($this->path . 'images/icons/16/change_password.svg'), window_Open('change_password_window', 350, $this->getLanguageConstant('title_change_password'), true, false, backend_UrlMake($this->name, 'change_password')), $level = 1)); $system_menu->addChild(null, new backend_MenuItem($this->getLanguageConstant('menu_logout'), url_GetFromFilePath($this->path . 'images/icons/16/logout.svg'), window_Open('logout_window', 350, $this->getLanguageConstant('title_logout'), true, false, backend_UrlMake($this->name, 'logout')), $level = 1)); $this->addMenu($this->name, $system_menu); } }
/** * Constructor */ protected function __construct() { parent::__construct(__FILE__); Events::connect('contact_form', 'email-sent', 'handleEmailSent', $this); }
/** * Handle drawing checkout form * * @param array $tag_params * @param array $children */ public function tag_CheckoutForm($tag_params, $children) { $account_information = array(); $shipping_information = array(); $billing_information = array(); $payment_method = null; $stage = isset($_REQUEST['stage']) ? fix_chars($_REQUEST['stage']) : null; $recurring = isset($_SESSION['recurring_plan']) && !empty($_SESSION['recurring_plan']); // decide whether to include shipping and account information if (isset($tag_params['include_shipping'])) { $include_shipping = fix_id($tag_params['include_shipping']) == 1; } else { $include_shipping = true; } $bad_fields = array(); $info_available = false; // grab user information if (!is_null($stage)) { // get payment method $payment_method = $this->getPaymentMethod($tag_params); if (is_null($payment_method)) { throw new PaymentMethodError('No payment method selected!'); } // get billing information $billing_information = $this->getBillingInformation($payment_method); $billing_required = array('billing_full_name', 'billing_card_type', 'billing_credit_card', 'billing_expire_month', 'billing_expire_year', 'billing_cvv'); $bad_fields = $this->checkFields($billing_information, $billing_required, $bad_fields); // get shipping information if ($include_shipping && $stage == 'set_info') { $shipping_information = $this->getShippingInformation(); $shipping_required = array('name', 'email', 'street', 'city', 'zip', 'country'); $bad_fields = $this->checkFields($shipping_information, $shipping_required, $bad_fields); } } $info_available = count($bad_fields) == 0 && !is_null($payment_method); if ($info_available) { $address_manager = ShopDeliveryAddressManager::getInstance(); $currency_manager = ShopCurrenciesManager::getInstance(); // get fields for payment method $return_url = url_Make('checkout_completed', 'shop', array('payment_method', $payment_method->get_name())); $cancel_url = url_Make('checkout_canceled', 'shop', array('payment_method', $payment_method->get_name())); // get currency info $currency = $this->settings['default_currency']; $currency_item = $currency_manager->getSingleItem(array('id'), array('currency' => $currency)); if (is_object($currency_item)) { $transaction_data['currency'] = $currency_item->id; } // get buyer $buyer = $this->getUserAccount(); if ($include_shipping) { $address = $this->getAddress($buyer, $shipping_information); } else { $address = null; } // update transaction $transaction_type = $recurring ? TransactionType::SUBSCRIPTION : TransactionType::SHOPPING_CART; $summary = $this->updateTransaction($transaction_type, $payment_method, '', $buyer, $address); // emit signal and return if handled if ($stage == 'set_info') { Events::trigger('shop', 'before-checkout', $payment_method->get_name(), $return_url, $cancel_url); foreach ($result_list as $result) { if ($result) { $this->showCheckoutRedirect(); return; } } } // create new payment if ($recurring) { // recurring payment $checkout_fields = $payment_method->new_recurring_payment($_SESSION['recurring_plan'], $billing_information, $return_url, $cancel_url); } else { // regular payment $checkout_fields = $payment_method->new_payment($transaction_data, $billing_information, $summary['items_for_checkout'], $return_url, $cancel_url); } // load template $template = $this->loadTemplate($tag_params, 'checkout_form.xml'); $template->registerTagHandler('cms:checkout_items', $this, 'tag_CheckoutItems'); $template->registerTagHandler('cms:delivery_methods', $this, 'tag_DeliveryMethodsList'); // parse template $params = array('checkout_url' => $payment_method->get_url(), 'checkout_fields' => $checkout_fields, 'checkout_name' => $payment_method->get_title(), 'currency' => $this->getDefaultCurrency(), 'recurring' => $recurring, 'include_shipping' => $include_shipping); // for recurring plans add additional params if ($recurring) { $plans = $payment_method->get_recurring_plans(); $plan_name = $_SESSION['recurring_plan']; $plan = $plans[$plan_name]; $params['plan_name'] = $plan['name']; $params['plan_description'] = $this->formatRecurring(array('price' => $plan['price'], 'period' => $plan['interval_count'], 'period' => $plan['interval_count'], 'unit' => $plan['interval'], 'setup' => $plan['setup_price'], 'trial_period' => $plan['trial_count'], 'trial_unit' => $plan['trial'])); } else { $params['sub-total'] = number_format($summary['total'], 2); $params['shipping'] = number_format($summary['shipping'], 2); $params['handling'] = number_format($summary['handling'], 2); $params['total_weight'] = number_format($summary['weight'], 2); $params['total'] = number_format($summary['total'] + $summary['shipping'] + $summary['handling'], 2); } $template->restoreXML(); $template->setLocalParams($params); $template->parse(); } else { // no information available, show form $template = new TemplateHandler('buyer_information.xml', $this->path . 'templates/'); $template->setMappedModule($this->name); $template->registerTagHandler('cms:card_type', $this, 'tag_CardType'); // get fixed country if set $fixed_country = ''; if (isset($this->settings['fixed_country'])) { $fixed_country = $this->settings['fixed_country']; } $params = array('include_shipping' => $include_shipping, 'fixed_country' => $fixed_country, 'bad_fields' => $bad_fields, 'recurring' => $recurring); $template->restoreXML(); $template->setLocalParams($params); $template->parse(); } }