Skip to content

Commit

Permalink
Merge branch 'main' into topic-autoloader
Browse files Browse the repository at this point in the history
  • Loading branch information
fballiano authored Oct 5, 2024
2 parents b8fc991 + 2cc09e0 commit e2cd0a4
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 41 deletions.
18 changes: 14 additions & 4 deletions app/code/core/Mage/Checkout/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
class Mage_Checkout_Helper_Data extends Mage_Core_Helper_Abstract
{
public const XML_PATH_GUEST_CHECKOUT = 'checkout/options/guest_checkout';
public const XML_PATH_REDIRECT_REGISTER = 'checkout/options/redirect_register';

/** @deprecated 24.11.0 use XML_PATH_REDIRECT_REGISTER instead */
public const XML_PATH_CUSTOMER_MUST_BE_LOGGED = 'checkout/options/customer_must_be_logged';

protected $_moduleName = 'Mage_Checkout';
Expand Down Expand Up @@ -330,14 +333,21 @@ public function isContextCheckout()
return (Mage::app()->getRequest()->getParam('context') == 'checkout');
}

/**
* Check if we should redirect the user to a separate register step during checkout
*/
public function isRedirectRegisterStep(): bool
{
return Mage::getStoreConfigFlag(self::XML_PATH_REDIRECT_REGISTER);
}

/**
* Check if user must be logged during checkout process
*
* @return bool
* @deprecated 24.11.0 use isRedirectRegisterStep() instead
*/
public function isCustomerMustBeLogged()
public function isCustomerMustBeLogged(): bool
{
return Mage::getStoreConfigFlag(self::XML_PATH_CUSTOMER_MUST_BE_LOGGED);
return $this->isRedirectRegisterStep();
}

public function isPersistentEnabled(): bool
Expand Down
11 changes: 0 additions & 11 deletions app/code/core/Mage/Checkout/Model/Type/Onepage.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,17 +190,6 @@ public function getCheckoutMethod()
return $this->getQuote()->getCheckoutMethod();
}

/**
* Get quote checkout method
*
* @deprecated since 1.4.0.1
* @return string
*/
public function getCheckoutMehod()
{
return $this->getCheckoutMethod();
}

/**
* Specify checkout method
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ protected function _canShowForUnregisteredUsers()
return Mage::getSingleton('customer/session')->isLoggedIn()
|| $this->getRequest()->getActionName() == 'index'
|| Mage::helper('checkout')->isAllowedGuestCheckout($this->getOnepage()->getQuote())
|| !Mage::helper('checkout')->isCustomerMustBeLogged();
|| !Mage::helper('checkout')->isRedirectRegisterStep();
}

/**
Expand Down
11 changes: 6 additions & 5 deletions app/code/core/Mage/Checkout/etc/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* @package Mage_Checkout
* @copyright Copyright (c) 2006-2020 Magento, Inc. (https://magento.com)
* @copyright Copyright (c) 2017-2023 The OpenMage Contributors (https://openmage.org)
* @copyright Copyright (c) 2024 Maho (https://mahocommerce.com)
* @license https://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
-->
Expand Down Expand Up @@ -45,16 +46,16 @@
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</guest_checkout>
<customer_must_be_logged translate="label">
<label>Require Customer To Be Logged In To Checkout</label>
<redirect_register translate="label">
<label>Use Separate Register Step</label>
<comment><![CDATA["If enabled, customers choosing to register during checkout will be redirected to the customer/account/create page.<br />Note: If email confirmation is required, users won't be able to complete the order before confirming their email."]]></comment>
<frontend_type>select</frontend_type>
<source_model>adminhtml/system_config_source_yesno</source_model>
<depends><guest_checkout>0</guest_checkout></depends>
<sort_order>15</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>0</show_in_store>
</customer_must_be_logged>
<show_in_store>1</show_in_store>
</redirect_register>
<enable_agreements translate="label">
<label>Enable Terms and Conditions</label>
<frontend_type>select</frontend_type>
Expand Down
30 changes: 30 additions & 0 deletions app/code/core/Mage/Checkout/sql/maho_setup/maho-24.10.0.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
/**
* Maho
*
* @category Mage
* @package Mage_Core
* @copyright @copyright Copyright (c) 2024 Maho (https://mahocommerce.com)
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/


const XML_PATH_GUEST_CHECKOUT = 'checkout/options/guest_checkout';
const XML_PATH_REDIRECT_REGISTER = 'checkout/options/redirect_register';
const XML_PATH_CUSTOMER_MUST_BE_LOGGED = 'checkout/options/customer_must_be_logged';

/** @var Mage_Checkout_Model_Resource_Setup $installer */
$installer = $this;

$defaultConfigValue = false;
foreach (Mage::app()->getWebsites(true) as $website) {
$configValue = !$website->getConfig(XML_PATH_GUEST_CHECKOUT) && $website->getConfig(XML_PATH_CUSTOMER_MUST_BE_LOGGED);
if ($website->getId() === 0) {
$defaultConfigValue = $configValue;
$this->setConfigData(XML_PATH_REDIRECT_REGISTER, $configValue);
} elseif ($configValue !== $defaultConfigValue) {
$this->setConfigData(XML_PATH_REDIRECT_REGISTER, true, 'websites', $website->getId());
}
}

$installer->endSetup();
12 changes: 8 additions & 4 deletions app/code/core/Mage/Core/Model/Resource/Setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -765,10 +765,14 @@ protected function _getModifySqlFiles($actionType, $fromVersion, $toVersion, $ar
case self::TYPE_MAHO:
uksort($arrFiles, 'version_compare');
foreach ($arrFiles as $version => $file) {
$arrRes[] = [
'toVersion' => $version,
'fileName' => $file
];
if (version_compare($version, $fromVersion) === self::VERSION_COMPARE_GREATER
&& version_compare($version, $toVersion) !== self::VERSION_COMPARE_GREATER
) {
$arrRes[] = [
'toVersion' => $version,
'fileName' => $file
];
}
}
break;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
?>
<?php
$isRegistrationAllowed = $this->helper('customer')->isRegistrationAllowed();
$isRedirectRegisterStep = $this->helper('checkout')->isRedirectRegisterStep();
$isAllowedGuestCheckout = $this->helper('checkout')->isAllowedGuestCheckout($this->getQuote());
$isCustomerMustBeLogged = $this->helper('checkout')->isCustomerMustBeLogged();
$isPersistentEnabled = $this->helper('checkout')->isPersistentEnabled();
?>
<?php /* Extensions placeholder */ ?>
Expand Down Expand Up @@ -59,17 +59,9 @@ $isPersistentEnabled = $this->helper('checkout')->isPersistentEnabled();

<div class="buttons-set">
<p class="required">&nbsp;</p>
<?php if ($isAllowedGuestCheckout): ?>
<button id="onepage-guest-register-button" type="button" class="button" onclick="checkout.setMethod();"><?= $this->__('Continue') ?></button>
<?php elseif ($isCustomerMustBeLogged): ?>
<button id="onepage-guest-register-button" type="button" class="button" onclick="window.location='<?= $this->helper('checkout/url')->getRegistrationUrl();?>'"><?= $this->__('Register') ?></button>
<?php elseif ($isPersistentEnabled): ?>
<form action="<?= $this->getUrl('persistent/index/saveMethod') ?>">
<button id="onepage-guest-register-button" type="submit" class="button"><?= $this->__('Register') ?></button>
</form>
<?php else: ?>
<button id="onepage-guest-register-button" type="button" class="button" onclick="checkout.setMethod();"><?= $this->__('Register') ?></button>
<?php endif ?>
<button id="onepage-guest-register-button" type="button" class="button">
<?= $this->__($isAllowedGuestCheckout ? 'Continue' : 'Register') ?>
</button>
</div>
</div>
<?php endif ?>
Expand Down Expand Up @@ -105,27 +97,45 @@ $isPersistentEnabled = $this->helper('checkout')->isPersistentEnabled();
</fieldset>
</form>
<div class="buttons-set">
<button type="submit" class="button" onclick="onepageLogin(this)"><?= $this->__('Login') ?></button>
<button id="onepage-login-button" type="submit" class="button"><?= $this->__('Login') ?></button>
</div>
</div>
</div>
<?php $registerParam = $this->getRequest()->getParam('register') ?>
<script type="text/javascript">
const loginForm = new VarienForm('login-form', true);

document.getElementById('login-email').addEventListener('keypress', bindLoginPost);
document.getElementById('login-password').addEventListener('keypress', bindLoginPost);
function bindLoginPost(evt) {
if (evt.keyCode == Event.KEY_RETURN) {
loginForm.submit();
}
}
function onepageLogin(button) {

document.getElementById('onepage-login-button').addEventListener('click', onepageLogin);
function onepageLogin() {
if(loginForm.validator && loginForm.validator.validate()){
button.disabled = true;
this.disabled = true;
loginForm.submit();
}
}

document.getElementById('onepage-guest-register-button').addEventListener('click', onepageRegisterOrGuest);
function onepageRegisterOrGuest() {
if (document.getElementById('login:register').checked) {
<?php if ($isRedirectRegisterStep): ?>
window.location = '<?= $this->quoteEscape($this->helper('checkout/url')->getRegistrationUrl()) ?>';
<?php elseif($isPersistentEnabled): ?>
window.location = '<?= $this->quoteEscape($this->getUrl('persistent/index/saveMethod')) ?>';
<?php else: ?>
checkout.setMethod();
<?php endif; ?>
} else if(document.getElementById('login:guest').checked) {
checkout.setMethod();
}
}

<?php if ($registerParam || $registerParam === ''): ?>
document.addEventListener("DOMContentLoaded", function() {
const registerCheckbox = document.getElementById('login:register');
Expand Down
3 changes: 2 additions & 1 deletion app/locale/en_US/Mage_Checkout.csv
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@
"Grouped Product Image","Grouped Product Image"
"HTML","HTML"
"ID","ID"
"If enabled, customers choosing to register during checkout will be redirected to the customer/account/create page.<br />Note: If email confirmation is required, users won't be able to complete the order before confirming their email.","If enabled, customers choosing to register during checkout will be redirected to the customer/account/create page.<br />Note: If email confirmation is required, users won't be able to complete the order before confirming their email."
"Incl. Tax","Incl. Tax"
"Invalid checkout type.","Invalid checkout type."
"Invalid data.","Invalid data."
Expand Down Expand Up @@ -257,7 +258,6 @@
"Remove item","Remove item"
"Remove product from shopping cart","Remove product from shopping cart"
"Remove product(s) from shopping cart","Remove product(s) from shopping cart"
"Require Customer To Be Logged In To Checkout","Require Customer To Be Logged In To Checkout"
"Retrieve information about shopping cart","Retrieve information about shopping cart"
"Review Order","Review Order"
"Review Order - %s","Review Order - %s"
Expand Down Expand Up @@ -341,6 +341,7 @@
"Update product quantities in shopping cart","Update product quantities in shopping cart"
"Update product(s) quantities in shopping cart","Update product(s) quantities in shopping cart"
"Use Billing Address","Use Billing Address"
"Use Separate Register Step","Use Separate Register Step"
"VAT Number","VAT Number"
"View Shopping Cart","View Shopping Cart"
"We are processing your order and you will soon receive an email with details of the order. Once the order has shipped you will receive another email with a link to track its progress.","We are processing your order and you will soon receive an email with details of the order. Once the order has shipped you will receive another email with a link to track its progress."
Expand Down

0 comments on commit e2cd0a4

Please sign in to comment.