Application requirements, defined under Chapter 4, Requirement Specification for Modular Web Shop App, do not give us any specifics as to what type of shipment we need to implement. Thus, for the purpose of this chapter, we will develop two shipment methods: dynamic rate shipment and flat rate shipment. Dynamic rate shipment is used as a way of connecting the shipment method to a real shipment processor, such as UPS, FedEx, and so on. It will not, however, actually connect to any of the external APIs.
Ideally, we want this done by an interface similar to the following:
namespace Foggyline\SalesBundle\Interface; interface Shipment { function getInfo($street, $city, $country, $postcode, $amount, $qty); function process($street, $city, $country, $postcode, $amount, $qty); }
The getInfo
method can then be used to fetch the available delivery options for the given order information, while the process method would then process the selected delivery option. For example, we might...