/** * Boot up the core plugin * * @author Jonathan Davis * @since 1.3 * * @return void **/ public static function plugin() { global $Shopp; // Provide global for backwards compatibility $Shopp = Shopp::object(); do_action('shopp_loaded'); }
/** * Registers a smart collection of products * * @api * @since 1.2 * * @param string $name Class name of the smart collection * @return void **/ function shopp_register_collection($name = '') { if (empty($name)) { shopp_debug(__FUNCTION__ . " failed: Collection name required."); return false; } $Shopp = Shopp::object(); $namespace = apply_filters('shopp_smart_collections_slug', SmartCollection::$namespace); $permastruct = SmartCollection::$taxon; $slugs = SmartCollection::slugs($name); $slug = $slugs[0]; $Shopp->Collections[$slug] = $name; do_action('shopp_register_collection', $name, $slug); $slugs = SmartCollection::slugs($name); add_rewrite_tag("%{$permastruct}%", "([^/]+)"); add_permastruct($permastruct, ShoppPages()->baseslug() . "/{$namespace}/%shopp_collection%", false); add_filter($permastruct . '_rewrite_rules', array('ProductCollection', 'pagerewrites')); $apicall = create_function('$result, $options, $O', 'ShoppCollection( new ' . $name . '($options) ); return ShoppStorefrontThemeAPI::category($result, $options, $O);'); foreach ((array) $slugs as $collection) { $collection = str_replace(array('-', '_'), '', $collection); // Sanitize slugs add_filter('shopp_themeapi_storefront_' . $collection . 'products', $apicall, 10, 3); // @deprecated add_filter('shopp_themeapi_storefront_' . $collection . 'collection', $apicall, 10, 3); } // Add special default permalink handling for collection URLs (only add it once) global $wp_rewrite; if (!$wp_rewrite->using_permalinks() && false === has_filter('term_link', array('SmartCollection', 'defaultlinks'))) { add_filter('term_link', array('SmartCollection', 'defaultlinks'), 10, 3); } }
function widget($args, $options) { $Shopp = Shopp::object(); extract($args); $title = $before_title . $options['title'] . $after_title; unset($options['title']); $content = shopp('storefront', 'get-sideproduct', $options); if (empty($content)) { return false; } echo $before_widget . $title . $content . $after_widget; }
function widget($args, $options) { $Shopp = Shopp::object(); extract($args); $title = $before_title . $options['title'] . $after_title; unset($options['title']); if (empty(ShoppCollection()->id)) { return false; } $menu = shopp(ShoppCollection(), 'get-section-list', $options); echo $before_widget . $title . $menu . $after_widget; }
function widget($args, $options) { $Shopp = Shopp::object(); if (!empty($args)) { extract($args); } if (empty($options['title'])) { $options['title'] = "Product Tags"; } $title = $before_title . $options['title'] . $after_title; $tagcloud = shopp('catalog', 'get-tagcloud', $options); echo $before_widget . $title . $tagcloud . $after_widget; }
function widget($args, $options) { $Shopp = Shopp::object(); if (!empty($args)) { extract($args); } if (empty($options['title'])) { $options['title'] = __('Shop Search', 'Shopp'); } $title = $before_title . $options['title'] . $after_title; $content = shopp('catalog', 'get-searchform'); echo $before_widget . $title . $content . $after_widget; }
public function screen() { $Shopp = Shopp::object(); if (!current_user_can('shopp_settings_checkout')) { wp_die(__('You do not have sufficient permissions to access this page.')); } $purchasetable = ShoppDatabaseObject::tablename(ShoppPurchase::$table); $next = sDB::query("SELECT IF ((MAX(id)) > 0,(MAX(id)+1),1) AS id FROM {$purchasetable} LIMIT 1"); $next_setting = shopp_setting('next_order_id'); if ($next->id > $next_setting) { $next_setting = $next->id; } $term_recount = false; if (!empty($_POST['save'])) { check_admin_referer('shopp-setup-management'); $next_order_id = $_POST['settings']['next_order_id'] = intval($_POST['settings']['next_order_id']); if ($next_order_id >= $next->id) { if (sDB::query("ALTER TABLE {$purchasetable} AUTO_INCREMENT=" . sDB::escape($next_order_id))) { $next_setting = $next_order_id; } } $_POST['settings']['order_shipfee'] = Shopp::floatval($_POST['settings']['order_shipfee']); // Recount terms when this setting changes if (isset($_POST['settings']['inventory']) && $_POST['settings']['inventory'] != shopp_setting('inventory')) { $term_recount = true; } shopp_set_formsettings(); $this->notice(Shopp::__('Management settings saved.'), 'notice', 20); } if ($term_recount) { $taxonomy = ProductCategory::$taxon; $terms = get_terms($taxonomy, array('hide_empty' => 0, 'fields' => 'ids')); if (!empty($terms)) { wp_update_term_count_now($terms, $taxonomy); } } $states = array(__('Map the label to an order state:', 'Shopp') => array_merge(array('' => ''), Lookup::txnstatus_labels())); $statusLabels = shopp_setting('order_status'); $statesLabels = shopp_setting('order_states'); $reasonLabels = shopp_setting('cancel_reasons'); if (empty($reasonLabels)) { $reasonLabels = array(__('Not as described or expected', 'Shopp'), __('Wrong size', 'Shopp'), __('Found better prices elsewhere', 'Shopp'), __('Product is missing parts', 'Shopp'), __('Product is defective or damaaged', 'Shopp'), __('Took too long to deliver', 'Shopp'), __('Item out of stock', 'Shopp'), __('Customer request to cancel', 'Shopp'), __('Item discontinued', 'Shopp'), __('Other reason', 'Shopp')); } $promolimit = array('1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '15', '20', '25'); $lowstock = shopp_setting('lowstock_level'); if (empty($lowstock)) { $lowstock = 0; } include $this->ui('management.php'); }
public function updates() { $CatalogPage = ShoppPages()->get('catalog'); $catalog_slug = $CatalogPage->slug(); $defaults = ShoppPages()->settings(); $this->form['storefront_pages'] = array_merge($defaults, $this->form('storefront_pages')); shopp_set_formsettings(); // Re-register page, collection, taxonomies and product rewrites // so that the new slugs work immediately $Shopp = Shopp::object(); $Shopp->pages(); $Shopp->collections(); $Shopp->taxonomies(); $Shopp->products(); // If the catalog slug changes // $hardflush is false (soft flush... plenty of fiber, no .htaccess update needed) $hardflush = ShoppPages()->baseslug() != $catalog_slug; flush_rewrite_rules($hardflush); }
/** * Resets plugin data when deactivated * * @author Jonathan Davis * @since 1.1 * * @return void **/ public function deactivate() { $Shopp = Shopp::object(); // Update rewrite rules (cleanup Shopp rewrites) remove_action('shopp_init', array($Shopp, 'pages')); remove_filter('rewrite_rules_array', array($Shopp, 'rewrites')); flush_rewrite_rules(); shopp_set_setting('data_model', ''); if (function_exists('get_site_transient')) { $plugin_updates = get_site_transient('update_plugins'); } else { $plugin_updates = get_transient('update_plugins'); } unset($plugin_updates->response[SHOPP_PLUGINFILE]); if (function_exists('set_site_transient')) { set_site_transient('update_plugins', $plugin_updates); } else { set_transient('update_plugins', $plugin_updates); } return true; }
public static function addons($meta, $plugin) { if (SHOPP_PLUGINFILE != $plugin) { return $meta; } $Shopp = Shopp::object(); $builtin = array('Shopp2Checkout', 'ShoppPayPalStandard', 'ShoppOfflinePayment', 'ShoppTestMode', 'FreeOption', 'ItemQuantity', 'ItemRates', 'OrderAmount', 'OrderRates', 'OrderWeight', 'PercentageAmount', 'DBStorage', 'FSStorage'); $builtin = array_flip($builtin); $modules = array_merge($Shopp->Gateways->modules, $Shopp->Shipping->modules, $Shopp->Storage->modules); $installed = array_diff_key($modules, $builtin); if (empty($installed)) { return $meta; } $label = Shopp::_mi('**Add-ons:**'); foreach ($installed as $addon) { $entry = array($label, $addon->name, $addon->version); if ($label) { $label = ''; } $meta[] = trim(join(' ', $entry)); } return $meta; }
/** * Add a sub-menu to a Shopp menu * * @api * @since 1.3 * * @param string $label The translated label to use for the menu * @param string $page The Shopp-internal menu page name (plugin prefix will be automatically added) * @param string $menu The Shopp-internal menu page name to append the submenu to * @param mixed $handler The callback handler to use to handle the page * @param string $access The access capability required to see the menu * @return integer The position the menu was added **/ function shopp_admin_add_submenu($label, $page, $menu = null, $handler = false, $access = null) { $Admin = ShoppAdmin(); if (is_null($menu)) { $Admin->mainmenu(); } if (is_null($access)) { $access = 'none'; } // Restrict access by default if (false === $handler) { $handler = array(Shopp::object()->Flow, 'admin'); } if (!is_callable($handler)) { shopp_debug(__FUNCTION__ . " failed: The specified callback handler is not valid."); return false; } $menupage = add_submenu_page($menu, $label, $label, $access, $page, $handler); $Admin->menu($page, $menupage); $Admin->addtab($page, $menu); do_action("shopp_add_menu_{$page}"); return $menupage; }
public function prepare_items() { $active = (array) shopp_setting('active_shipping'); $Shopp = Shopp::object(); $Shipping = $Shopp->Shipping; $Shipping->settings(); // Load all installed shipping modules for settings UIs $Shipping->ui(); // Setup setting UIs $settings = array(); // Registry of loaded settings for table-based shipping rates for JS $this->items = array(); // Registry for activated shipping rate modules $this->installed = array(); // Registry of available shipping modules installed foreach ($Shipping->active as $name => $Module) { if (version_compare($Shipping->modules[$name]->since, '1.2') == -1) { continue; } // Skip 1.1 modules, they are incompatible $default_name = strtolower($name); $fullname = $Module->methods(); $this->installed[$name] = $fullname; if ($Module->ui->tables) { $defaults[$default_name] = $Module->ui->settings(); $defaults[$default_name]['name'] = $fullname; $defaults[$default_name]['label'] = Shopp::__('Shipping Method'); } if (array_key_exists($name, $active)) { $ModuleSetting = $active[$name]; } else { continue; } // Not an activated shipping module, go to the next one $Entry = new StdClass(); $Entry->id = sanitize_title_with_dashes($name); $Entry->label = $Shipping->modules[$name]->name; $Entry->type = $Shipping->modules[$name]->name; $Entry->setting = $name; if ($this->request('id') == $Entry->setting) { $Entry->editor = $Module->ui(); } // Setup shipping service shipping rate entries and settings if (!is_array($ModuleSetting)) { $Entry->destinations = array($Shipping->active[$name]->destinations); $this->items[$name] = $Entry; continue; } // Setup shipping calcualtor shipping rate entries and settings foreach ($ModuleSetting as $id => $m) { $Entry->setting = "{$name}-{$id}"; $Entry->settings = shopp_setting($Entry->setting); if ($this->request('id') == $Entry->setting) { $Entry->editor = $Module->ui(); } if (isset($Entry->settings['label'])) { $Entry->label = $Entry->settings['label']; } $Entry->destinations = array(); $min = $max = false; if (isset($Entry->settings['table']) && is_array($Entry->settings['table'])) { foreach ($Entry->settings['table'] as $tablerate) { $destination = false; $d = ShippingSettingsUI::parse_location($tablerate['destination']); if (!empty($d['zone'])) { $Entry->destinations[] = $d['zone'] . ' (' . $d['countrycode'] . ')'; } elseif (!empty($d['area'])) { $Entry->destinations[] = $d['area']; } elseif (!empty($d['country'])) { $Entry->destinations[] = $d['country']; } elseif (!empty($d['region'])) { $Entry->destinations[] = $d['region']; } } if (!empty($Entry->destinations)) { $Entry->destinations = array_keys(array_flip($Entry->destinations)); } // Combine duplicate destinations } $this->items[$Entry->setting] = $Entry; $settings[$Entry->setting] = shopp_setting($Entry->setting); $settings[$Entry->setting]['id'] = $Entry->setting; $settings[$Entry->setting] = array_merge($defaults[$default_name], $settings[$Entry->setting]); if (isset($settings[$Entry->setting]['table'])) { usort($settings[$Entry->setting]['table'], array('ShippingFramework', '_sorttier')); foreach ($settings[$Entry->setting]['table'] as &$r) { if (isset($r['tiers'])) { usort($r['tiers'], array('ShippingFramework', '_sorttier')); } } } } // end foreach ( $ModuleSetting ) } // end foreach ( $Shipping->active ) $this->set_pagination_args(array('total_items' => count($this->items), 'total_pages' => 1)); $postcodes = ShoppLookup::postcodes(); foreach ($postcodes as &$postcode) { $postcode = !empty($postcode); } $lookup = array('regions' => array_merge(array('*' => Shopp::__('Anywhere')), ShoppLookup::regions()), 'regionmap' => ShoppLookup::regions('id'), 'countries' => ShoppLookup::countries(), 'areas' => ShoppLookup::country_areas(), 'zones' => ShoppLookup::country_zones(), 'postcodes' => $postcodesscre); shopp_custom_script('shiprates', ' var shipping = ' . json_encode(array_map('sanitize_title_with_dashes', array_keys($this->installed))) . ', defaults = ' . json_encode($defaults) . ', settings = ' . json_encode($settings) . ', lookup = ' . json_encode($lookup) . ';'); }
/** * Provides overall layout for the order manager interface * * Makes use of WordPress postboxes to generate panels (box) content * containers that are customizable with drag & drop, collapsable, and * can be toggled to be hidden or visible in the interface. * * @author Jonathan Davis * @return **/ public function layout() { $Shopp = Shopp::object(); $Admin =& $Shopp->Flow->Admin; ShoppUI::register_column_headers($this->screen, apply_filters('shopp_order_manager_columns', array('items' => __('Items', 'Shopp'), 'qty' => __('Quantity', 'Shopp'), 'price' => __('Price', 'Shopp'), 'total' => __('Total', 'Shopp')))); include $this->ui('events.php'); include $this->ui('ui.php'); do_action('shopp_order_manager_layout'); }
public function storage_ui() { $Shopp = Shopp::object(); $Shopp->Storage->settings(); $Shopp->Storage->ui(); }
/** * Determines if the current request is for a registered dynamic Shopp collection * * NOTE: This function will not identify PHP loaded collections, it only * compares the page request, meaning using is_shopp_collection on the catalog landing * page, even when the landing page (catalog.php) template loads the CatalogProducts collection * will return false, because CatalogProducts is loaded in the template and not directly * from the request. * * @api * @since 1.2 * * @param WP_Query $wp_query (optional) will use the global wp_query by default if false, or the WP_Query object to evaluation * @return boolean **/ function is_shopp_smart_collection($wp_query = false) { if (false === $wp_query) { global $wp_the_query; $wp_query =& $wp_the_query; } $slug = $wp_query->get('shopp_collection'); if (empty($slug)) { return false; } $Shopp = Shopp::object(); foreach ((array) $Shopp->Collections as $Collection) { $slugs = SmartCollection::slugs($Collection); if (in_array($slug, $slugs)) { return true; } } return false; }
/** * Provide the customer account page URL * * @api `shopp('customer.url')` * @since 1.0 * * @param string $result The output * @param array $options The options * @param ShoppCustomer $O The working object * @return string The page URL **/ public static function url($result, $options, $O) { $Shopp = Shopp::object(); return Shopp::url(array('acct' => null), 'account', $Shopp->Gateways->secure); }
/** * Handles product file download requests * * @author Jonathan Davis * @since 1.1 * * @return void **/ public function download() { $Shopp = Shopp::object(); $download = $this->request['shopp_download']; $Purchase = false; $Purchased = false; if (defined('WP_ADMIN')) { $forbidden = false; $Download = new ProductDownload($download); } else { $Order = ShoppOrder(); $accounts = 'none' != shopp_setting('account_system'); $Download = new ProductDownload(); $Download->loadby_dkey($download); $Purchased = $Download->purchased(); $Purchase = new ShoppPurchase($Purchased->purchase); $Purchase->load_events(); $name = $Purchased->name . (!empty($Purchased->optionlabel) ? ' (' . $Purchased->optionlabel . ')' : ''); $forbidden = false; // Voided orders if ($Purchase->isvoid()) { shopp_add_error(Shopp::__('"%s" cannot be downloaded because the order has been cancelled.', $name)); $forbidden = true; } // Purchase Completion check if (!$Purchase->ispaid() && !SHOPP_PREPAYMENT_DOWNLOADS) { shopp_add_error(Shopp::__('"%s" cannot be downloaded because payment has not been received yet.', $name)); $forbidden = true; } // If accounts are used and this is not a guest account if ($accounts && Shopp::__('Guest') != ShoppCustomer()->type) { // User must be logged in when accounts are being used if (!ShoppCustomer()->loggedin()) { shopp_add_error(Shopp::__('You must login to download purchases.')); $forbidden = true; } // Logged in account must be the owner of the purchase if (ShoppCustomer()->id != $Purchase->customer) { shopp_add_error(Shopp::__('You are not authorized to download the requested file.')); $forbidden = true; } } // Download limit checking if (shopp_setting('download_limit') && $Purchased->downloads + 1 > shopp_setting('download_limit')) { shopp_add_error(Shopp::__('"%s" is no longer available for download because the download limit has been reached.', $name)); $forbidden = true; } // Download expiration checking if (shopp_setting('download_timelimit') && $Purchased->created + shopp_setting('download_timelimit') < current_time('timestamp')) { shopp_add_error(Shopp::__('"%s" is no longer available for download because it has expired.', 'Shopp', $name)); $forbidden = true; } // IP restriction checks if ('ip' == shopp_setting('download_restriction') && !empty($Purchase->ip) && $Purchase->ip != $_SERVER['REMOTE_ADDR']) { shopp_add_error(Shopp::__('"%s" cannot be downloaded because your computer could not be verified as the system the file was purchased from.', $name)); $forbidden = true; } do_action_ref_array('shopp_download_request', array($Purchased)); } if (apply_filters('shopp_download_forbidden', $forbidden, $Purchased)) { Shopp::redirect(add_query_arg('downloads', '', Shopp::url(false, 'account')), true, 303); } // Send the download $download = $Download->download(); if (is_a($download, 'ShoppError')) { // If the result is an error redirect to the account downloads page Shopp::redirect(add_query_arg('downloads', '', Shopp::url(false, 'account')), true, 303); } else { do_action_ref_array('shopp_download_success', array($Purchased, $Purchase, $Download)); // @deprecated use shopp_download_order_event instead shopp_add_order_event($Purchase->id, 'download', array('purchased' => $Purchased->id, 'download' => $Download->id, 'ip' => ShoppShopping()->ip, 'customer' => ShoppCustomer()->id)); } exit; }
/** * Provides the billing locale drop-down menu markup or the currently selected billing locale * * @api `shopp('checkout.billing-locale')` * @since 1.0 * * @param string $result The output * @param array $options The options * - **mode**: `input` (input, value) Displays the field `input` or the current value of the property * - **accesskey**: Specifies a shortcut key to activate/focus an element. Linux/Windows: `[Alt]`+`accesskey`, Mac: `[Ctrl]``[Opt]`+`accesskey` * - **class**: `paycard` The class attribute specifies one or more class-names for an element * - **disabled**: Specifies that an `<input>` element should be disabled * - **size**: Specifies number of options to show at one time in the menu * - **tabindex**: Specifies the tabbing order of an element * - **title**: Specifies extra information about an element * - **selected**: The currently selected billing locale * @param ShoppOrder $O The working object * @return string The generated markup or value **/ public static function billing_locale($result, $options, $O) { $Shopp = Shopp::object(); $select_attrs = array('title', 'class', 'disabled', 'required', 'size', 'tabindex', 'accesskey'); $output = false; $defaults = array('mode' => 'input', 'selected' => $O->Billing->locale ? $O->Billing->locale : false); $options = array_merge($defaults, $options); if ('value' == $options['mode']) { return $O->Billing->locale; } $rates = shopp_setting('taxrates'); foreach ($rates as $rateset) { // @todo - what if more than one set of local rates applies to current country/zone? ie. conditions if (isset($rateset['locals'])) { $locales[$rateset['country'] . $rateset['zone']] = array_keys($rateset['locals']); } } // if there are local tax jurisdictions in settings if (!empty($locales)) { // Add all the locales to the javascript environment add_storefrontjs('var locales = ' . json_encode($locales) . ';', true); // $Taxes = new CartTax(); $Tax = ShoppOrder()->Tax; // Check for local rates applying to current country/zone $settings = $Tax->settings(); foreach ($settings as $setting) { if (isset($setting['locals'])) { $localities = array_keys($setting['locals']); break; } } // Make this a required field $options['required'] = true; // disable this field automatically if no local jurisdictions apply to current country.zone if (empty($localities)) { $options['disabled'] = 'disabled'; } // Start stub select menu for billing local tax jurisdiction (needed for javascript to populate) $output = '<select name="billing[locale]" id="billing-locale" ' . inputattrs($options, $select_attrs) . '>'; if (!empty($localities)) { $output .= "<option></option>" . menuoptions($localities, $options['selected']); } // End stub select menu for billing local tax jurisdiction $output .= '</select>'; } return $output; }
public function setobject($Object, $context) { if (is_object($Object)) { return $Object; } // always use if first argument is an object $api = $this->classname; $apicontext = call_user_func(array($api, '_apicontext')); if (strtolower($context) != strtolower($apicontext)) { return $Object; } // do nothing $Shopp = Shopp::object(); $property = ucfirst($apicontext); if (property_exists($Shopp, $property)) { return $Shopp->{$property}; } return false; }
/** * Determines the activated gateway modules * * @author Jonathan Davis * @since 1.1 * * @return array List of module names for the activated modules **/ public function activated() { $Shopp = Shopp::object(); $this->activated = array(); $gateways = explode(',', shopp_setting('active_gateways')); $modules = array_keys($this->modules); foreach ($gateways as $gateway) { $moduleclass = $this->moduleclass($gateway); if (!empty($moduleclass)) { $this->activated[$gateway] = $moduleclass; } } return $this->activated; }
/** * Handles rendering the [catalog-collection] shortcode * * @author Jonathan Davis * @since 1.1 * * @param array $attrs The parsed shortcode attributes * @return string The processed content **/ static function collection(array $atts = array()) { $Shopp = Shopp::object(); $tag = 'category'; if (isset($atts['name'])) { $Collection = new ProductCategory($atts['name'], 'name'); unset($atts['name']); } elseif (isset($atts['slug'])) { foreach ($Shopp->Collections as $SmartCollection) { $slugs = SmartCollection::slugs($SmartCollection); if (in_array($atts['slug'], $slugs)) { $tag = $slugs[0] . "-collection"; unset($atts['slug']); break; } } } elseif (isset($atts['id'])) { $Collection = new ProductCategory($atts['id']); unset($atts['id']); } else { return ''; } ShoppCollection($Collection); $markup = shopp("catalog.get-{$tag}", $atts); ShoppStorefront()->shortcoded[] = get_the_ID(); // @deprecated in favor of the shopp_collection_shortcode $markup = apply_filters('shopp_category_shortcode', $markup); return apply_filters('shopp_collection_shortcode', $markup); }
/** * Interface processor for the product editor * * @author Jonathan Davis * @return void **/ public function editor() { $Shopp = Shopp::object(); if (!current_user_can('shopp_products')) { wp_die(__('You do not have sufficient permissions to access this page.')); } if (empty($Shopp->Product)) { $Product = new ShoppProduct(); $Product->status = "publish"; } else { $Product = $Shopp->Product; } $Product->slug = apply_filters('editable_slug', $Product->slug); $permalink = trailingslashit(Shopp::url()); $Price = new ShoppPrice(); $priceTypes = ShoppPrice::types(); $billPeriods = ShoppPrice::periods(); $workflows = array('continue' => Shopp::__('Continue Editing'), 'close' => Shopp::__('Products Manager'), 'new' => Shopp::__('New Product'), 'next' => Shopp::__('Edit Next'), 'previous' => Shopp::__('Edit Previous')); $taglist = array(); foreach ($Product->tags as $tag) { $taglist[] = $tag->name; } if ($Product->id && !empty($Product->images)) { $ids = join(',', array_keys($Product->images)); $CoverImage = reset($Product->images); $image_table = $CoverImage->_table; $Product->cropped = sDB::query("SELECT * FROM {$image_table} WHERE context='image' AND type='image' AND '2'=SUBSTRING_INDEX(SUBSTRING_INDEX(name,'_',4),'_',-1) AND parent IN ({$ids})", 'array', 'index', 'parent'); } $shiprates = shopp_setting('shipping_rates'); if (!empty($shiprates)) { ksort($shiprates); } $uploader = shopp_setting('uploader_pref'); if (!$uploader) { $uploader = 'flash'; } $process = empty($Product->id) ? 'new' : $Product->id; $_POST['action'] = add_query_arg(array_merge($_GET, array('page' => $this->Admin->pagename('products'))), admin_url('admin.php')); $post_type = ShoppProduct::posttype(); // Re-index menu options to maintain order in JS #2930 if (isset($Product->options['v']) || isset($Product->options['a'])) { $options = array_keys($Product->options); foreach ($options as $type) { foreach ($Product->options[$type] as $id => $menu) { $Product->options[$type][$type . $id] = $menu; $Product->options[$type][$type . $id]['options'] = array_values($menu['options']); unset($Product->options[$type][$id]); } } } else { foreach ($Product->options as &$menu) { $menu['options'] = array_values($menu['options']); } } do_action('add_meta_boxes', ShoppProduct::$posttype, $Product); do_action('add_meta_boxes_' . ShoppProduct::$posttype, $Product); do_action('do_meta_boxes', ShoppProduct::$posttype, 'normal', $Product); do_action('do_meta_boxes', ShoppProduct::$posttype, 'advanced', $Product); do_action('do_meta_boxes', ShoppProduct::$posttype, 'side', $Product); include $this->ui('editor.php'); }
/** * Adds change tracking to the shipping rates system for automagic recalculations * * @author Jonathan Davis * @since 1.3 * * @return void **/ public function tracking() { $Shopp = Shopp::object(); $ShippingModules = $Shopp->Shipping; $Order = ShoppOrder(); $ShippingAddress = $Order->Shipping; $Shiprates = $Order->Shiprates; if (empty($Shiprates)) { return; } // Tell Shiprates to track changes for this data... $Shiprates->track('shipcountry', $ShippingAddress->country); $Shiprates->track('shipstate', $ShippingAddress->state); $Shiprates->track('shippostcode', $ShippingAddress->postcode); // Hash items for lower memory tracking $this->shipped(); $Shiprates->track('items', $this->shipped); $Shiprates->track('modules', $ShippingModules->active); $Shiprates->track('postcodes', $ShippingModules->postcodes); $Shiprates->track('realtime', $ShippingModules->realtime); }
/** * Returns the product adjacent to the requested product in the category * * @author Jonathan Davis * @since 1.1 * * @param int $next (optional) Which product to get (-1 for previous, defaults to 1 for next) * @return object The Product object **/ public function adjacent_product($next = 1) { $Shopp = Shopp::object(); if ($next < 0) { $this->loading['adjacent'] = "previous"; } else { $this->loading['adjacent'] = "next"; } $this->loading['limit'] = '1'; $this->loading['product'] = $Shopp->Requested; $this->load_products(); if (!$this->loaded) { return false; } reset($this->products); $product = key($this->products); return new ShoppProduct($product); }
/** * Filters the WP page list transforming unsecured URLs to secure URLs * * @author Jonathan Davis * @since 1.1 * * @return void **/ public function securelinks($items) { $Shopp = Shopp::object(); if (!$Shopp->Gateways->secure) { return $items; } $hrefs = array('checkout' => Shopp::url(false, 'checkout'), 'account' => Shopp::url(false, 'account')); if (empty($Shopp->Gateways->active)) { return str_replace($hrefs['checkout'], Shopp::url(false, 'cart'), $items); } foreach ($hrefs as $href) { $secure_href = str_replace('http://', 'https://', $href); $items = str_replace($href, $secure_href, $items); } return $items; }
public function pages() { if (!current_user_can('shopp_settings')) { wp_die(__('You do not have sufficient permissions to access this page.')); } if (!empty($_POST['save'])) { check_admin_referer('shopp-settings-pages'); $CatalogPage = ShoppPages()->get('catalog'); $catalog_slug = $CatalogPage->slug(); $defaults = ShoppPages()->settings(); $_POST['settings']['storefront_pages'] = array_merge($defaults, $_POST['settings']['storefront_pages']); shopp_set_formsettings(); // Re-register page, collection, taxonomies and product rewrites // so that the new slugs work immediately $Shopp = Shopp::object(); $Shopp->pages(); $Shopp->collections(); $Shopp->taxonomies(); $Shopp->products(); // If the catalog slug changes // $hardflush is false (soft flush... plenty of fiber, no .htaccess update needed) $hardflush = ShoppPages()->baseslug() != $catalog_slug; flush_rewrite_rules($hardflush); } $pages = ShoppPages()->settings(); include $this->ui('pages.php'); }
/** * Interface processor for the promotion editor * @author Jonathan Davis * @return void **/ public function editor() { $Shopp = Shopp::object(); if (!current_user_can('shopp_promotions')) { wp_die(__('You do not have sufficient permissions to access this page.')); } if ('new' !== $_GET['id']) { $Promotion = new ShoppPromo($_GET['id']); do_action('shopp_discount_promo_loaded', $Promotion); } else { $Promotion = new ShoppPromo(); } $this->disabled_alert($Promotion); include $this->ui('editor.php'); }
public function gateway() { $Gateways = Shopp::object()->Gateways; $processor = $this->gateway; if ('ShoppFreeOrder' == $processor) { return $Gateways->freeorder; } $Gateway = $Gateways->get($processor); if (!$Gateway) { foreach ($Gateways->active as $Gateway) { if ($processor == $Gateway->name) { return $Gateway; } } } else { return $Gateway; } return false; }
/** * Builds the interface layout for the customer editor * * @author Jonathan Davis * @return void **/ public function layout() { $Shopp = Shopp::object(); $Admin = ShoppAdmin(); $Customer = $this->Model; $default = array('' => ' '); $countries = array_merge($default, ShoppLookup::countries()); $Customer->_countries = $countries; $states = ShoppLookup::country_zones(array($Customer->Billing->country, $Customer->Shipping->country)); $Customer->_billing_states = array_merge($default, (array) $states[$Customer->Billing->country]); $Customer->_shipping_states = array_merge($default, (array) $states[$Customer->Shipping->country]); new ShoppAdminCustomerSaveBox($this->id, 'side', 'core', array('Customer' => $Customer)); new ShoppAdminCustomerSettingsBox($this->id, 'side', 'core', array('Customer' => $Customer)); new ShoppAdminCustomerLoginBox($this->id, 'side', 'core', array('Customer' => $Customer)); new ShoppAdminCustomerContactBox($this->id, 'normal', 'core', array('Customer' => $Customer)); if (!empty($Customer->info->meta) && is_array($Customer->info->meta)) { new ShoppAdminCustomerInfoBox($this->id, 'normal', 'core', array('Customer' => $Customer)); } new ShoppAdminCustomerBillingAddressBox($this->id, 'normal', 'core', array('Customer' => $Customer)); new ShoppAdminCustomerShippingAddressBox($this->id, 'normal', 'core', array('Customer' => $Customer)); }
/** * Interface processor for the customer editor * * Handles rendering the interface, processing updated customer details * and handing saving them back to the database * * @author Jonathan Davis * @return void **/ function editor() { global $ruletypes, $rulegroups; $Shopp = Shopp::object(); if (!current_user_can('shopp_memberships')) { wp_die(__('You do not have sufficient permissions to access this page.')); } if ($_GET['id'] != "new") { $MemberPlan = new MemberPlan($_GET['id']); if (empty($MemberPlan->id)) { wp_die(__('The requested membership record does not exist.', 'Shopp')); } $MemberPlan->load_stages(); $MemberPlan->load_access(); } else { $MemberPlan = new MemberPlan(); } $skip = array('created', 'modified', 'numeral', 'context', 'type', 'sortorder', 'parent'); foreach ($MemberPlan->stages as &$Stage) { foreach ($Stage->rules as &$rules) { foreach ($rules as &$Access) { if (method_exists($Access, 'json')) { $Access = $Access->json($skip); } } } $Stage = $Stage->json($skip); } include SHOPP_ADMIN_PATH . "/memberships/editor.php"; }