コード例 #1
0
ファイル: Taxes.php プロジェクト: msigley/shopp
    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 = [];
		');
    }