0

I'm looking on how to check if i'm standing at checkout payment page, which have url "fudu.magento.net/checkout/#payment" by php or by js. I was trying to use to get url, but it always return checkout_index_index

To be clear, i want to compare between shipping page and payment page, which have url is "checkout/#shipping" and "checkout/#payment".

EDIT 1: I've trying using script to check css display:none of #shipping, but it doesn't work either, because when i click "next" in shipping page, it will not render any js out after that.

my js code:

function checkIfPaymentPage(){
                if($('#shipping').css('display') == 'none'){
                    console.log('worked');
                }
            }

After i click "next", nothing appear in inspect console:

enter image description here

EDIT 1:


I'm using window.setInterval(function(){ //code }, 3000); and it worked for me to testing, but i don't thing this is the best practice, so if you guys have any other solutions, please tell me :)

Thanks for reading.

  • In which file you want to check ? – Rohan Hapani Oct 24 '18 at 12:53
  • I want to check it in my custom phtml file, or Block, or Helper, anything that can check it :) Thanks – fudu Oct 24 '18 at 13:21
  • Please check my answer. Maybe it will helpful for you. – Rohan Hapani Oct 24 '18 at 13:28
0

To get checkout page url, try this:

<?php echo $block->getUrl('checkout', ['_secure' => true]);?>

Hope it works.

  • Doesn't work, i var_dump it and got this string(57) "http://fudu.magento.net/index.php/checkout/" – fudu Oct 24 '18 at 13:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.