Skip to content

Commit

Permalink
#144: "Honor" max address-book entries
Browse files Browse the repository at this point in the history
... when billing/shipping addresses are updated for non-guest checkout.
  • Loading branch information
lat9 committed Jun 28, 2018
1 parent 2faffff commit c23f449
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion YOUR_ADMIN/includes/init_includes/init_checkout_one.php
Expand Up @@ -15,7 +15,7 @@
// 500-599 ... Registered-account settings
// 1000+ ..... Debug settings
//
define('CHECKOUT_ONE_CURRENT_VERSION', '2.0.4-beta3');
define('CHECKOUT_ONE_CURRENT_VERSION', '2.0.4-beta4');
define('CHECKOUT_ONE_CURRENT_UPDATE_DATE', '2018-06-28');

if (isset($_SESSION['admin_id'])) {
Expand Down
1 change: 1 addition & 0 deletions docs/one_page_checkout/readme.html
Expand Up @@ -690,6 +690,7 @@ <h3>Check for jQuery Errors</h3>
<ul>
<li>v2.0.4, 2018-07-xx:<ul>
<li>BUGFIX: &quot;Suburb&quot; (aka &quot;Address Line 2&quot;) and/or &quot;Company&quot; not saved when an address is updated.</li>
<li>BUGFIX: Maximum address-book entries not honored.</li>
<li>The following files were affected:<ol>
<li>/includes/classes/OnePageCheckout.php</li>
<li>/YOUR_ADMIN/includes/init_includes/init_checkout_one.php</li>
Expand Down
16 changes: 14 additions & 2 deletions includes/classes/OnePageCheckout.php
Expand Up @@ -513,11 +513,23 @@ public function validateGuestPaymentMethods($enabled_payment_modules)
** the module whether (true) or not (false) to include the checkbox to add the updated
** address.
**
** The field is displayed unless the checkout is being performed in guest-mode.
** The field is displayed only during an account-holder checkout, where that customer does
** not (yet) have the maximum number of address-book entries.
*/
public function showAddAddressField()
{
return !zen_in_guest_checkout();
$show_add_address = false;
if (!zen_in_guest_checkout() && !empty($_SESSION['customer_id'])) {
$check = $GLOBALS['db']->Execute(
"SELECT COUNT(*) as count
FROM " . TABLE_ADDRESS_BOOK . "
WHERE customers_id = " . (int)$_SESSION['customer_id']
);
if ($check->fields['count'] < (int)MAX_ADDRESS_BOOK_ENTRIES) {
$show_add_address = true;
}
}
return $show_add_address;
}

/* -----
Expand Down

0 comments on commit c23f449

Please sign in to comment.