public function forSelection() { $term = $this->input->get('q', null, 'default'); $key = new \MongoRegex('/' . $term . '/i'); $results = \Shop\Models\Regions::forSelection(array('name' => $key)); $response = new \stdClass(); $response->more = false; $response->term = $term; $response->results = $results; return $this->outputJson($response); }
> </div> <div class="row"> <div class="form-group col-xs-12 col-sm-12 col-md-6"> <select class="form-control region billing-region" data-required="true" data-shipping="<?php echo $cart->{'checkout.shipping_address.region'}; ?> " name="checkout[billing_address][region]" autocomplete="region" <?php if ($cart->billingSameAsShipping()) { echo 'disabled'; } ?> > <option value=""> - Please Select - </option> <?php foreach (\Shop\Models\Regions::byCountry($cart->billingCountry($cart->shippingCountry())) as $region) { ?> <option value="<?php echo $region->code; ?> " <?php if ($cart->billingRegion($cart->{'checkout.shipping_address.region'}) == $region->code) { echo "selected"; } ?> ><?php echo $region->name; ?> </option> <?php }
<input type="text" class="form-control address" name="line_2" value="<?php echo $flash->old('line_2'); ?> " placeholder="Address Line 2" autocomplete="address-line2"> </div> <div class="form-group"> <input type="text" class="form-control city" data-required="true" name="city" value="<?php echo $flash->old('city'); ?> " placeholder="City" autocomplete="locality"> </div> <div class="row"> <div class="form-group col-xs-12 col-sm-12 col-md-6"> <select class="form-control region" data-required="true" name="region" id="region" autocomplete="region"> <?php foreach (\Shop\Models\Regions::byCountry($selected_country) as $region) { ?> <option value="<?php echo $region->code; ?> " <?php if ($flash->old('region') == $region->code) { echo "selected"; } ?> ><?php echo $region->name; ?> </option> <?php }
public static function byCountry($country_isocode_2) { return \Shop\Models\Regions::find(array('country_isocode_2' => $country_isocode_2)); }
</div> <div class="row"> <div class="col-md-12"> <label>City</label> <input name="store_address[city]" placeholder="City" value="<?php echo $flash->old('store_address.city'); ?> " class="form-control" type="text" /> </div> </div> <div class="row"> <div class="col-xs-12 col-sm-12 col-md-6"> <label>Region</label> <select id="shipping-region" class="form-control region" name="store_address[region]"> <?php foreach (\Shop\Models\Regions::byCountry($flash->old('store_address.country')) as $region) { ?> <option value="<?php echo $region->code; ?> " <?php if ($flash->old('store_address.region') == $region->code) { echo "selected"; } ?> ><?php echo $region->name; ?> </option> <?php }
dataType: 'json', data: function (term, page) { return { q: term }; }, results: function (data, page) { return {results: data.results}; } } <?php if ($flash->old('geo_regions')) { ?> , initSelection : function (element, callback) { var data = <?php echo json_encode(\Shop\Models\Regions::initSelection($flash->old('geo_regions'))); ?> ; callback(data); } <?php } ?> }); }); </script> <hr /> <div class="row">
/** * Gets a list of regions, filtered by a country isocode_2 */ public function regions() { $f3 = \Base::instance(); $country_isocode_2 = $f3->get('PARAMS.country_isocode_2'); $result = \Shop\Models\Regions::byCountry($country_isocode_2); return $this->outputJson($this->getJsonResponse(array('message' => \Dsc\System::instance()->renderMessages(), 'result' => $result))); }