Skip to content

Instantly share code, notes, and snippets.

@bouassaba
Created December 13, 2014 23:11
Show Gist options
  • Save bouassaba/561c7075c533c7da2fe4 to your computer and use it in GitHub Desktop.
Save bouassaba/561c7075c533c7da2fe4 to your computer and use it in GitHub Desktop.
magento update cart and checkout
<?php if ($this->isPossibleOnepageCheckout()):?>
<script type="text/javascript">
// <![CDATA[
function updateAndGoto(url) {
var cartForm = $$('.cart form').first();
var action = cartForm.readAttribute('action');
if (action.indexOf('return_url') < 0) {
var glue = action.indexOf('?') < 0 ? '?' : '&';
action += glue + 'return_url=' + url;
cartForm.writeAttribute('action', action);
}
cartForm.submit();
}
// ]]>
</script>
<button type="button" title="<?php echo $this->__('Proceed to Checkout') ?>" class="button btn-proceed-checkout btn-checkout<?php if ($this->isDisabled()):?> no-checkout<?php endif; ?>"<?php if ($this->isDisabled()):?> disabled="disabled"<?php endif; ?> onclick="updateAndGoto('<?php echo $this->getCheckoutUrl() ?>');"><span><span><?php echo $this->__('Proceed to Checkout') ?></span></span></button>
<?php endif?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment