LemonStand Documentation

Shop_Country

The Shop_Country class represents a country. You can manage countries and states on the System/Countries page. You may need to work with objects of this class when you create the Billing Information and Shipping information steps of the Checkout page. Usually you do not need to create objects of this class manually. The shop:checkout action automatically creates a list of states in the $countries variable. Please refer the Creating the Checkout page article for details.

Parent class: Db_ActiveRecord

Class fields

  • $id - the country database identifier
  • $name – a country name
  • $code – a 2-symbol country code (US)
  • $code_3 – a 3-symbol country code (USA)
  • $code_iso_numeric – a 3-digit country code (840)
  • $states – a collection of country states. An object of the Db_DataCollection class. Each element of the collection is an object of the Shop_CountryState class.

Class methods

  • static create() - creates an instance of the class
  • find_by_code($code) - finds a country by the 2-symbol country code (for example 'US'). Returns an object of the Shop_Country class. You can use the following code for loading a specific country from the database:
    $usa = Shop_Country::create()->find_by_code('US');
  • find_by_id($id) - loads a country by its identifier. Example: 
    $country = Shop_Country::create()->find_by_id(1);

Next: Shop_CountryState
Previous: Shop_ComparisonList
Return to Reference

Comments

No comments posted so far.

Add your comment

Loading form...