function __construct() { if ('none' == shopp_setting('account_system')) { return parent::__construct('shopp-order-lookup', __('Shopp Order Lookup', 'Shopp'), array('description' => __('Lookup orders by order number and email', 'Shopp'))); } parent::__construct('shopp-account', __('Shopp Account', 'Shopp'), array('description' => __('Customer account management dashboard', 'Shopp'))); }
/** * Builds a list of payment method options * * @author Jonathan Davis * @since 1.1.5 * * @return void **/ public function options() { $options = array(); $accepted = array(); $processors = array(); $gateways = explode(',', shopp_setting('active_gateways')); foreach ($gateways as $gateway) { $id = false; if (false !== strpos($gateway, '-')) { list($module, $id) = explode('-', $gateway); } else { $module = $gateway; } $GatewayModule = $this->modules($module); if (!$GatewayModule) { continue; } if ($GatewayModule->secure) { $this->secure = true; } $settings = $GatewayModule->settings; if (false !== $id && isset($settings[$id])) { $settings = $settings[$id]; } $slug = sanitize_title_with_dashes($settings['label']); $PaymentOption = new ShoppPaymentOption($slug, $settings['label'], $GatewayModule->module, $gateway, array_keys($GatewayModule->cards())); $options[$slug] = $PaymentOption; $processors[$PaymentOption->processor] = $slug; $accepted = array_merge($accepted, $GatewayModule->cards()); } $this->populate($options); $this->cards = $accepted; $this->processors = $processors; }
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'); }
function chartseries($label, array $options = array()) { if (!$this->Chart) { $this->initchart(); } extract($options); if ($record->stocked == 0) { return; } $threshold = shopp_setting('lowstock_level'); $warning = $record->inventory / $record->stocked * 100 < $threshold; $this->Chart->series($record->product, array('color' => $warning ? '#A90007' : '#CB4B16', 'data' => array(array($index, $record->stocked)))); $backordered = 0 > $record->inventory; $this->Chart->series($record->product, array('color' => $backordered ? '#dc322f' : '#1C63A8', 'data' => array(array($index, $record->inventory)))); }
function getCountryID() { return 209; $country = strtoupper(shopp_setting('base_operations')); switch ($country) { case 'SE': return 209; case 'FI': return 73; case 'DK': return 59; case 'NO': return 164; default: return 209; } }
public static function login($result) { $Customer = ShoppOrder()->Customer; if ($Customer->loggedin()) { return $result; } $accounts = shopp_setting('account_system'); $pleaselogin = '******' . Shopp::__('If you have an account with us, please login now.'); // This specific !isset condition checks if the loginname is not provided // If no loginname is provided, but an account system is used, we need to // generate a new login name for the customer if ('wordpress' == $accounts && !isset($_POST['loginname'])) { ShoppLoginGenerator::object(); $_POST['loginname'] = ShoppLoginGenerator::name(); if (apply_filters('shopp_login_required', empty($_POST['loginname']))) { return shopp_add_error(Shopp::__('A login could not be created with the information you provided. Enter a different name or email address.') . $pleaselogin); } shopp_debug('Login set to ' . $_POST['loginname'] . ' for WordPress account creation.'); } // Validate unique email address for new account if (in_array($accounts, array('wordpress', 'shopp')) && !$Customer->session(ShoppCustomer::GUEST)) { $ShoppCustomer = new ShoppCustomer($_POST['email'], 'email'); if (apply_filters('shopp_email_exists', 'wordpress' == $accounts ? email_exists($_POST['email']) : $ShoppCustomer->exists())) { return shopp_add_error(Shopp::__('The email address you entered is already in use. Enter a different email address to create a new account.') . $pleaselogin); } } // Validate WP login if (isset($_POST['loginname'])) { if (apply_filters('shopp_login_required', empty($_POST['loginname']))) { return shopp_add_error(Shopp::__('You must enter a login name for your account.')); } if (apply_filters('shopp_login_valid', !validate_username($_POST['loginname']))) { $sanitized = sanitize_user($_POST['loginname'], true); $illegal = array_diff(str_split($_POST['loginname']), str_split($sanitized)); return shopp_add_error(Shopp::__('The login name provided includes invalid characters: %s', esc_html(join(' ', $illegal)))); } if (apply_filters('shopp_login_exists', username_exists($_POST['loginname']))) { return shopp_add_error(Shopp::__('"%s" is already in use. Enter a different login name to create a new account.', esc_html($_POST['loginname'])) . $pleaselogin); } } return $result; }
/** * Filters the tax settings based on * * @author Jonathan Davis * @since 1.3 * * @return array A list of tax rate settings **/ public function settings() { if (!shopp_setting_enabled('taxes')) { return false; } $taxrates = shopp_setting('taxrates'); $fallbacks = array(); $settings = array(); foreach ((array) $taxrates as $setting) { $defaults = array('rate' => 0, 'country' => '', 'zone' => '', 'haslocals' => false, 'logic' => 'any', 'rules' => array(), 'localrate' => 0, 'compound' => false, 'label' => Shopp::__('Tax')); $setting = array_merge($defaults, $setting); extract($setting); if (!$this->taxcountry($country)) { continue; } if (!$this->taxzone($zone)) { continue; } if (!$this->taxrules($rules, $logic)) { continue; } // Capture fall back tax rates if (empty($zone) && self::ALL == $country) { $fallbacks[] = $setting; continue; } $key = hash('crc32b', serialize($setting)); // Key settings before local rates $setting['localrate'] = 0; if (isset($setting['locals']) && is_array($setting['locals']) && isset($setting['locals'][$this->address['locale']])) { $setting['localrate'] = $setting['locals'][$this->address['locale']]; } $settings[$key] = $setting; } if (empty($settings) && !empty($fallbacks)) { $settings = $fallbacks; } $settings = apply_filters('shopp_cart_taxrate_settings', $settings); // @deprecated Use shopp_tax_rate_settings instead return apply_filters('shopp_tax_rate_settings', $settings); }
public function updates() { $builtin_path = SHOPP_PATH . '/templates'; $theme_path = sanitize_path(STYLESHEETPATH . '/shopp'); if (Shopp::str_true($this->form('theme_templates')) && !is_dir($theme_path)) { $this->form['theme_templates'] = 'off'; $this->notice(Shopp::__("Shopp theme templates can't be used because they don't exist."), 'error'); } if (empty($this->form('catalog_pagination'))) { $this->form['catalog_pagination'] = 0; } // Recount terms when this setting changes if ($this->form('outofstock_catalog') != shopp_setting('outofstock_catalog')) { $taxonomy = ProductCategory::$taxon; $terms = get_terms($taxonomy, array('hide_empty' => 0, 'fields' => 'ids')); if (!empty($terms)) { wp_update_term_count_now($terms, $taxonomy); } } shopp_set_formsettings(); $this->notice(Shopp::__('Presentation settings saved.'), 'notice', 20); }
function save_meta_box($Category) { $Shopp = Shopp::object(); $workflows = array("continue" => __('Continue Editing', 'Shopp'), "close" => __('Category Manager', 'Shopp'), "new" => __('New Category', 'Shopp'), "next" => __('Edit Next', 'Shopp'), "previous" => __('Edit Previous', 'Shopp')); ?> <div id="major-publishing-actions"> <input type="hidden" name="id" value="<?php echo $Category->id; ?> " /> <select name="settings[workflow]" id="workflow"> <?php echo Shopp::menuoptions($workflows, shopp_setting('workflow'), true); ?> </select> <input type="submit" class="button-primary" name="save" value="<?php _e('Update', 'Shopp'); ?> " /> </div> <?php }
public function screen() { if (!current_user_can('shopp_settings')) { wp_die(__('You do not have sufficient permissions to access this page.')); } // Welcome screen handling if (!empty($_POST['setup'])) { shopp_set_setting('display_welcome', 'off'); } $countries = ShoppLookup::countries(); $basecountry = ShoppBaseLocale()->country(); $countrymenu = Shopp::menuoptions($countries, $basecountry, true); $basestates = ShoppLookup::country_zones(array($basecountry)); $statesmenu = Shopp::menuoptions($basestates[$basecountry], ShoppBaseLocale()->state(), true); $targets = shopp_setting('target_markets'); if (is_array($targets)) { $targets = array_map('stripslashes', $targets); } if (!$targets) { $targets = array(); } $zones_ajaxurl = wp_nonce_url(admin_url('admin-ajax.php'), 'wp_ajax_shopp_country_zones'); include $this->ui('setup.php'); }
public function save(ShoppCustomer $Customer) { if ($this->request('new')) { if (!isset($this->valid_email)) { return $this->notice(Shopp::__('Could not create new customer. You must enter a valid email address.')); } if (!isset($this->valid_password)) { $this->password = wp_hash_password(wp_generate_password(12, true)); } if ('wordpress' !== shopp_setting('account_system')) { $wpuser = $Customer->create_wpuser(); $login = '******' . sanitize_user($this->form('userlogin')) . '</strong>'; if ($wpuser) { $this->notice(Shopp::__('A new customer has been created with the WordPress login "%s".', $login), 'error'); } else { $this->notice(Shopp::__('Could not create the WordPress login "%s" for the new customer.', $login), 'error'); } } $this->notice(Shopp::__('New customer created.')); } $Customer->save(); }
public static function process() { // We have to avoid truthiness, hence the strange logic expression if (true !== apply_filters('shopp_validate_registration', true)) { return; } $Customer = ShoppOrder()->Customer; do_action('shopp_customer_registration', $Customer); if ($Customer->session(ShoppCustomer::GUEST)) { $Customer->type = __('Guest', 'Shopp'); // No cuts $Customer->wpuser = 0; // No buts unset($Customer->password); // No coconuts } else { // WordPress account integration used, customer has no wp user if ('wordpress' == shopp_setting('account_system') && empty($Customer->wpuser)) { if ($wpuser = get_current_user_id()) { $Customer->wpuser = $wpuser; } else { $Customer->create_wpuser(); } // not logged in, create new account } if (!$Customer->exists(true)) { $Customer->id = false; shopp_debug('Creating new Shopp customer record'); if (empty($Customer->password)) { $Customer->password = wp_generate_password(12, true); } if ('shopp' == shopp_setting('account_system')) { $Customer->notification(); } $Customer->password = wp_hash_password($Customer->password); if (isset($Customer->passhash)) { $Customer->password = $Customer->passhash; } } else { unset($Customer->password); } // Existing customer, do not overwrite password field! } // New customer, save hashed password $Customer->save(); $Customer->password = ''; // Update billing and shipping addresses $addresses = array('Billing', 'Shipping'); foreach ($addresses as $Address) { if (empty(ShoppOrder()->{$Address}->address)) { continue; } $Address = ShoppOrder()->{$Address}; $Address->customer = $Customer->id; $Address->save(); } do_action('shopp_customer_registered', $Customer); // Auto-login $Customer->login(); // Login the customer if (!empty($Customer->wpuser)) { // Log the WordPress user in ShoppLogin::wpuser(get_user_by('id', $Customer->wpuser)); } if (apply_filters('shopp_registration_redirect', false)) { Shopp::redirect(Shopp::url(false, 'account')); } }
/** * Helper method to render markup for state/province input fields * * @internal * @since 1.3 * * @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 * - **type**: `menu` (menu, text) Changes the input type to a drop-down menu or text input field * - **options**: A comma-separated list of options for the drop-down menu when the **type** is set to `menu` * - **required**: `auto` (auto,on,off) Sets the field to be required automatically, always `on` or disabled `off` * - **class**: The class attribute specifies one or more class-names for the input * - **label**: The label shown as the default option of the drop-down menu when the **type** is set to `menu` * - **address**: `billing` (billing,shipping) Used to specify which address the field takes input for * @param ShoppCustomer $O The working object * @return string The state input markup **/ private static function state($result, $options, $O) { $defaults = array('mode' => 'input', 'type' => 'menu', 'options' => '', 'required' => 'auto', 'class' => '', 'label' => '', 'address' => 'billing'); $options = array_merge($defaults, $options); $options['address'] = self::valid_address($options['address']); $Address = self::AddressObject($options['address']); if (!isset($options['value'])) { $options['value'] = $Address->state; } $options['selected'] = $options['value']; $options['id'] = "{$options['address']}-state"; extract($options, EXTR_SKIP); if ('value' == $mode) { return $value; } $countries = (array) shopp_setting('target_markets'); $select_attrs = array('title', 'required', 'class', 'disabled', 'required', 'size', 'tabindex', 'accesskey'); $country = ShoppBaseLocale()->country(); if (!empty($Address->country)) { $country = $Address->country; } if (!array_key_exists($country, $countries)) { $country = key($countries); } $regions = Lookup::country_zones(); $states = isset($regions[$country]) ? $regions[$country] : array(); if (!empty($options['options']) && empty($states)) { $states = explode(',', $options['options']); } $classes = false === strpos($class, ' ') ? explode(' ', $class) : array(); $classes[] = $id; if ('auto' == $required) { unset($options['required']); // prevent inputattrs from handling required=auto $classes[] = 'auto-required'; } $options['class'] = join(' ', $classes); if ('text' == $type) { return '<input type="text" name="' . $address . '[state]" id="' . $id . '" ' . inputattrs($options) . '/>'; } $options['disabled'] = 'disabled'; $options['class'] = join(' ', array_merge($classes, array('disabled', 'hidden'))); $result = '<select name="' . $address . '[state]" id="' . $id . '-menu" ' . inputattrs($options, $select_attrs) . '>' . '<option value="">' . $label . '</option>' . (!empty($states) ? menuoptions($states, $selected, true) : '') . '</select>'; unset($options['disabled']); $options['class'] = join(' ', $classes); $result .= '<input type="text" name="' . $address . '[state]" id="' . $id . '" ' . inputattrs($options) . '/>'; return $result; }
public function __construct(ShoppReportFramework $Report) { $this->ReportClass = get_class($Report); $this->options = $Report->options; $Report->load(); $this->columns = $Report->columns(); $this->data = $Report->data; $this->records = $Report->total; $report = $this->options['report']; $settings = shopp_setting("{$report}_report_export"); $this->headings = Shopp::str_true($settings['headers']); $this->selected = $settings['columns']; }
/** * Loads the theme templates `shopp/functions.php` if present * * If theme content templates are enabled, checks for and includes a functions.php file (if present). * This allows developers to add Shopp-specific presentation logic with the added convenience of knowing * that shopp_init has run. * * @author Barry Hughes * @since 1.3 * * @return void **/ public static function functions() { if (!Shopp::str_true(shopp_setting('theme_templates'))) { return; } Shopp::locate_template(array('functions.php'), true); }
public function print_script_request() { global $compress_scripts; $zip = $compress_scripts ? 1 : 0; if ($zip && defined('ENFORCE_GZIP') && ENFORCE_GZIP) { $zip = 'gzip'; } $debug = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '&debug=1' : ''; if (!empty($this->concat)) { $ver = md5("{$this->concat_version}"); if (shopp_setting('script_server') == 'plugin') { $src = trailingslashit(get_bloginfo('url')) . "?sjsl=" . trim($this->concat, ', ') . "&c={$zip}&ver={$ver}" . $debug; if (is_ssl()) { $src = str_replace('http://', 'https://', $src); } } else { $src = SHOPP_PLUGINURI . "/services/scripts.php?c={$zip}&load=" . trim($this->concat, ', ') . "&ver={$ver}" . $debug; } echo "<script type='text/javascript' src='" . esc_attr($src) . "'></script>\n"; } if (!empty($this->print_code)) { echo "<script type='text/javascript'>\n"; echo "/* <![CDATA[ */\n"; echo $this->print_code; echo "/* ]]> */\n"; echo "</script>\n"; } if (!empty($this->print_html)) { echo $this->print_html; } }
public function prepare_items() { $this->id = 'taxrates'; $defaults = array('paged' => 1, 'per_page' => 25, 'action' => false); $args = array_merge($defaults, $_GET); extract($args, EXTR_SKIP); $rates = (array) shopp_setting('taxrates'); $this->items = array(); foreach ($rates as $index => $taxrate) { $this->items[$index] = array_merge(self::$template, array('id' => $index), $taxrate); } $specials = array(ShoppTax::ALL => Shopp::__('All Markets')); if (ShoppTax::euvat(false, ShoppBaseLocale()->country(), ShoppTax::EUVAT)) { $specials[ShoppTax::EUVAT] = Shopp::__('European Union'); } $this->countries = array_filter(array_merge($specials, (array) shopp_setting('target_markets'))); $this->zones = ShoppLookup::country_zones(); $total = count($this->items); $this->set_pagination_args(array('total_items' => $total, 'total_pages' => $total / $per_page, 'per_page' => $per_page)); shopp_custom_script('taxrates', ' var suggurl = "' . wp_nonce_url(admin_url('admin-ajax.php'), 'wp_ajax_shopp_suggestions') . '", rates = ' . json_encode($this->items) . ', zones = ' . json_encode($this->zones) . ', lookup = ' . json_encode(ShoppLookup::localities()) . ', taxrates = []; '); }
public static function settings() { ?> <div id="iif-settings" class="hidden"> <input type="text" id="iif-account" name="settings[purchaselog_iifaccount]" value="<?php echo shopp_setting('purchaselog_iifaccount'); ?> " size="30"/><br /> <label for="iif-account"><small><?php _e('QuickBooks account name for transactions', 'Shopp'); ?> </small></label> </div> <script type="text/javascript"> /* <![CDATA[ */ jQuery(document).ready( function($) { $('#purchaselog-format').change(function () { if ($(this).val() == "iif") { $('#export-columns').hide(); $('#iif-settings').show(); $('#iif-account').focus(); } else { $('#export-columns').show(); $('#iif-settings').hide(); } }).change(); }); /* ]]> */ </script> <?php }
/><label for="inclusive-tax-toggle"> <?php _e('Enabled', 'Shopp'); ?> </label><br /> <?php _e('Enable to include taxes in the price of goods.', 'Shopp'); ?> </td> </tr> <tr> <th scope="row" valign="top"><label for="tax-shipping-toggle"><?php _e('Tax Shipping', 'Shopp'); ?> </label></th> <td><input type="hidden" name="settings[tax_shipping]" value="off" /><input type="checkbox" name="settings[tax_shipping]" value="on" id="tax-shipping-toggle"<?php if (shopp_setting('tax_shipping') == "on") { echo ' checked="checked"'; } ?> /><label for="tax-shipping-toggle"> <?php _e('Enabled', 'Shopp'); ?> </label><br /> <?php _e('Enable to calculate tax for shipping and handling fees.', 'Shopp'); ?> </td> </tr> <?php do_action('shopp_taxes_settings_table'); ?>
<div id="image-storage-engine" class="storage-settings"><?php if ($ImageStorage) { echo $ImageStorage->ui('image'); } ?> </div> </td> </tr> <tr> <th scope="row" valign="top"><label for="download-storage"><?php _e('Product File Storage', 'Shopp'); ?> </label></th> <td><select name="settings[product_storage]" id="download-storage"> <?php echo Shopp::menuoptions($storage, shopp_setting('product_storage'), true); ?> </select><input type="submit" name="download-settings" value="<?php _e('Settings…', 'Shopp'); ?> " class="button-secondary hide-if-js"/> <div id="download-storage-engine" class="storage-settings"><?php if ($DownloadStorage) { echo $DownloadStorage->ui('download'); } ?> </div> </td> </tr> </table>
/** * Wraps mark-up in a #shopp container, if needed * * @author Jonathan Davis * @since 1.1 * * @param string $string The content markup to be wrapped * @param array $classes CSS classes to add to the container * @return string The wrapped markup **/ static function wrapper($string) { $classes = array('shoppage', 'shopp_page'); $views = array('list', 'grid'); $view = shopp_setting('default_catalog_view'); if (empty($view)) { $view = 'grid'; } // Handle catalog view style cookie preference if (isset($_COOKIE['shopp_catalog_view'])) { $view = $_COOKIE['shopp_catalog_view']; } if (in_array($view, $views)) { $classes[] = $view; } $boxes = shopp_setting('row_products'); if (empty($boxes)) { $boxes = 3; } $classes[] = 'shopp_grid-' . abs($boxes); // Add collection slug $Collection = ShoppCollection(); if (!empty($Collection)) { if ($category = shopp('collection.get-slug')) { $classes[] = $category; } } // Add product id & slug classes $Product = ShoppProduct(); if (!empty($Product)) { if ($productid = shopp('product.get-id')) { $classes[] = 'product-' . $productid; } if ($product = shopp('product.get-slug')) { $classes[] = $product; } } $classes = apply_filters('shopp_content_container_classes', $classes); $classes = esc_attr(join(' ', $classes)); $id = false === strpos($string, 'id="shopp"') ? ' id="shopp" ' : ''; return '<div' . $id . (!empty($classes) ? ' class="' . $classes . '"' : '') . '>' . $string . '</div>'; }
/** * Displays the shipping estimate widget * * The shipping estimate widget allows shoppers to provide location * information so that shipping costs can be calculated. * * @api `shopp('cart.shipping-estimates')` * @since 1.0 * * @param string $result The output * @param array $options The options * - **class**: CSS class names to apply to the widget * - **postcode**: `on` (on, off) Show the post code field in the widget * @param ShoppCart $O The working object * @return string The markup for the shipping estimate widget **/ public static function shipping_estimates($result, $options, $O) { $defaults = array('postcode' => 'on', 'class' => 'ship-estimates', 'label' => Shopp::__('Estimate Shipping & Taxes')); $options = array_merge($defaults, $options); extract($options); if (empty($O->shipped)) { return ''; } $markets = shopp_setting('target_markets'); $Shipping = ShoppOrder()->Shipping; if (empty($markets)) { return ''; } if (!empty($Shipping->country)) { $selected = $Shipping->country; } else { $selected = ShoppBaseLocale()->country(); } $postcode = Shopp::str_true($postcode) || $O->showpostcode; $_ = '<div class="' . $class . '">'; if (count($markets) > 1) { $_ .= '<span>'; $_ .= '<select name="shipping[country]" id="shipping-country">'; $_ .= menuoptions($markets, $selected, true); $_ .= '</select>'; $_ .= '</span>'; } else { $_ .= '<input type="hidden" name="shipping[country]" id="shipping-country" value="' . key($markets) . '" />'; } if ($postcode) { $_ .= '<span>'; $_ .= '<input type="text" name="shipping[postcode]" id="shipping-postcode" size="6" value="' . $Shipping->postcode . '"' . inputattrs($options) . ' /> '; $_ .= '</span>'; $_ .= shopp('cart', 'get-update-button', array('value' => $label)); } return $_ . '</div>'; }
weightUnit = '<?php echo shopp_setting('weight_unit'); ?> ', dimensionUnit = '<?php echo shopp_setting('dimension_unit'); ?> ', storage = '<?php echo shopp_setting('product_storage'); ?> ', productspath = '<?php /* realpath needed for relative paths */ chdir(WP_CONTENT_DIR); echo addslashes(trailingslashit(sanitize_path(realpath(shopp_setting('products_path'))))); ?> ', imageupload_debug = <?php echo defined('SHOPP_IMAGEUPLOAD_DEBUG') && SHOPP_IMAGEUPLOAD_DEBUG ? 'true' : 'false'; ?> , fileupload_debug = <?php echo defined('SHOPP_FILEUPLOAD_DEBUG') && SHOPP_FILEUPLOAD_DEBUG ? 'true' : 'false'; ?> , dimensionsRequired = <?php echo $Shopp->Shipping->dimensions ? 'true' : 'false'; ?> , startWeekday = <?php
echo $name; ?> " ><?php echo $label; ?> </label></li> <?php } ?> </ul> </div> <br /> <select name="settings[report_export_format]" id="report-format"> <?php echo menuoptions($exports, shopp_setting('report_export_format'), true); ?> </select> </div> <button type="submit" id="download-button" name="download" value="export" class="button-secondary"<?php if ($Report->total < 1) { echo ' disabled="disabled"'; } ?> ><?php _e('Download', 'Shopp'); ?> </button> <div class="clear"></div> </form> </div>
function login_meta_box($Customer) { $wp_user = get_userdata($Customer->wpuser); $avatar = get_avatar($Customer->wpuser, 48); $userlink = add_query_arg('user_id', $Customer->wpuser, admin_url('user-edit.php')); if ('wordpress' == shopp_setting('account_system')) { ?> <div class="alignleft avatar"> <?php if ($Customer->wpuser > 0) { ?> <a href="<?php echo esc_url($userlink); ?> "><?php } ?> <?php echo $avatar; if ($Customer->wpuser > 0) { ?> </a><?php } ?> </div> <p> <span> <input type="hidden" name="userid" id="userid" value="<?php echo esc_attr($Customer->wpuser); ?> " /> <input type="text" name="userlogin" id="userlogin" value="<?php echo esc_attr($wp_user->user_login); ?> " size="20" class="selectall" /><br /> <label for="userlogin"><?php _e('WordPress Login', 'Shopp'); ?> </label> </span> <?php } ?> <h4><?php _e('New Password', 'Shopp'); ?> </h4> <p> <input type="password" name="new-password" id="new-password" value="" size="20" class="selectall" /><br /> <label for="new-password"><?php _e('Enter a new password to change it.', 'Shopp'); ?> </label> </p> <p> <input type="password" name="confirm-password" id="confirm-password" value="" size="20" class="selectall" /><br /> <label for="confirm-password"><?php _e('Confirm the new password.', 'Shopp'); ?> </label> </p> <br class="clear" /> <div id="pass-strength-result"><?php _e('Strength indicator'); ?> </div> <br class="clear" /> <?php }
/** * Returns true or false if the setting is toggled on or off * * @api * @since 1.2 * * @param string $name The name of the setting * @return boolean True is enabled, false is disabled **/ function shopp_setting_enabled($name) { $setting = shopp_setting($name); return Shopp::str_true($setting); }
Shopp::_e('Enabled', 'Shopp'); ?> </label><br /> <?php Shopp::_e('Enables shipping cost calculations. Disable if you are exclusively selling intangible products.'); ?> </td> </tr> <tr> <th scope="row" valign="top"><label for="taxes-toggle"><?php Shopp::_e('Calculate Taxes'); ?> </label></th> <td><input type="hidden" name="settings[taxes]" value="off" /><input type="checkbox" name="settings[taxes]" value="on" id="taxes-toggle"<?php if (shopp_setting('taxes') == "on") { echo ' checked="checked"'; } ?> /><label for="taxes-toggle"> <?php Shopp::_e('Enabled', 'Shopp'); ?> </label><br /> <?php Shopp::_e('Enables tax calculations. Disable if you are exclusively selling non-taxable items.'); ?> </td> </tr> <tr> <th scope="row" valign="top"><label for="shipping-toggle"><?php
/** * Retrieves the number of orders in each customized order status label * * @author Jonathan Davis * @return void **/ public function status_counts() { $table = ShoppDatabaseObject::tablename(ShoppPurchase::$table); $labels = shopp_setting('order_status'); if (empty($labels)) { return false; } $status = array(); $alltotal = sDB::query("SELECT count(*) AS total FROM {$table}", 'auto', 'col', 'total'); $r = sDB::query("SELECT status,COUNT(status) AS total FROM {$table} GROUP BY status ORDER BY status ASC", 'array', 'index', 'status'); $all = array('' => __('All Orders', 'Shopp')); $labels = $all + $labels; foreach ($labels as $id => $label) { $_ = new StdClass(); $_->label = $label; $_->id = $id; $_->total = 0; if (isset($r[$id])) { $_->total = (int) $r[$id]->total; } if ('' === $id) { $_->total = $alltotal; } $status[$id] = $_; } return $status; }
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) . ';'); }
function apto_shopp_collection_query($options) { $orderby = shopp_setting('product_image_orderby'); if ($orderby != "sortorder") { return $options; } //create a csutom query then use the results as order $argv = array('post_type' => 'shopp_product', 'posts_per_page' => -1, 'fields' => 'ids'); if (isset($options['joins']['wp_term_taxonomy'])) { preg_match('/.*tt.term_id=([0-9]+)?.*/i', $options['joins']['wp_term_taxonomy'], $matches); if (isset($matches[1])) { $term_id = $matches[1]; $argv['tax_query'] = array(array('taxonomy' => 'shopp_category', 'field' => 'term_id', 'terms' => array($term_id))); } } $custom_query = new WP_Query($argv); if (!$custom_query->have_posts()) { return $options; } $posts_list = $custom_query->posts; if (count($posts_list) > 0) { global $wpdb; $options['orderby'] = " FIELD(p.ID, " . implode(",", $posts_list) . ") ASC"; } return $options; }