So here are my proposed files to accomplish the desired operation.
This was tested on a ZC 1.5.5 site and is primarily written for ZC 1.5.3+.
To explain, my thought process and implementation is this:
When customer arrives at the checkout_shipping page for the first time, there is no session set associated with the 'sendto' address. I take advantage of that information to "recognize" that this is the first time arriving at the checkout_shipping page. Then, I allow the header code to progress so that the "standard" checks are performed in preparation of the checkout_shipping page to be presented or in the case of someone "randomly" trying to go to the checkout_shipping page that they are redirected to the login page. In my opinion at this point it doesn't make sense to go straight to the shipping address area under the current request. So, at the end of the header file, if the beginning identified no sendto address was set, then to redirect to the checkout_shipping_address page. Expectation is that now at the checkout_shipping_address page, selection of the address is made and with the process "continuing" the customer is returned back to the checkout_shipping page and this time the sendto address ought to be set and processing continues as normal with the selected address filled in. If the customer returns to the checkout_shipping page, then whatever value remains in the 'sendto' address is what is used. This value is set upon return to the checkout_shipping page and even in the checkout_shipping_address page (if one is not set which is the condition that will exist at the end of the first load of the checkout_shipping page.
Anyways, try it out and see if it accomplishes the desired task.
To do this I propose a single observer file that will observe the checkout_shipping header start and end, with a variable maintained to link the information between the two.
For ZC 1.5.3. and above create a new file:\
includes/classes/observers/auto.force_checkout_shipping_address_load.php
For versions prior to ZC 1.5.3 well first suggest upgrading, second to to invoke the class file through an includes/auto_loaders or similar related file, and 3rd to insert/incorporate the includes/init_includes/init_observers.php file from a more up-to-date version of ZC.
Code:
<?php
/**
* observer class file to force the customer to go to the checkout_shipping_address screen when first stepping through the
* checkout process to try to force entry/selection of the destination address rather than just moving on with the default address.
* mc12345678.
*/
class zcObserverForceCheckoutShippingAddressLoad extends base {
private $_emptySendTo;
function __construct() {
$observeThis = array();
$observeThis[] = 'NOTIFY_HEADER_START_CHECKOUT_SHIPPING';
$observeThis[] = 'NOTIFY_HEADER_END_CHECKOUT_SHIPPING';
$this->attach($this, $observeThis); // Begin observing the above notifiers.
$this->_emptySendTo = false;
}
function updateNotifyHeaderStartCheckoutShipping(&$callingClass, $notifier) {
if (!array_key_exists('sendto', $_SESSION)) { // If the key sendto does not exist, then the address is not set. Other "related" conditions could be if it is set to false, or if it is set to NULL; however, testing for these conditions depends on the goal and previous operations.
$this->_emptySendTo = true;
} else { // The session is set to provide some address in the sendto field and the customer is not to be redirected as defined in updateNotifyHeaderEndCheckoutShipping
$this->_emptySendTo = false;
}
}
function updateNotifyHeaderEndCheckoutShipping(&$callingClass, $notifier) {
if ($this->_emptySendTo) {
unset($_SESSION['sendto']); // Clear the session of the send to address (set within the header_php.php file before this point) before sending to the checkout_shipping_address.
zen_redirect(zen_href_link(FILENAME_CHECKOUT_SHIPPING_ADDRESS, '', 'SSL'));
}
}
function update(&$callingClass, $notifier) {
if ($notifier == 'NOTIFY_HEADER_START_CHECKOUT_SHIPPING') {
$this->updateNotifyHeaderStartCheckoutShipping($callingClass, $notifier);
}
if ($notifier == 'NOTIFY_HEADER_END_CHECKOUT_SHIPPING') {
$this->updateNotifyHeaderEndCheckoutShipping($callingClass, $notifier);
}
}
}
Now, understand this though, and I had said it before about the possibility of using an otherwise existing modified checkout process, because this will result in customers having an "extra" screen through which to navigate to complete the purchase. But, it does accomplish the requested task of placing the address selection as a necessary action rather than just something else on the screen.
Bookmarks