Skip to content

Instantly share code, notes, and snippets.

@aadmathijssen
Forked from schmengler/add-checkout-form-key.sh
Last active October 29, 2019 13:52
Show Gist options
  • Save aadmathijssen/fa5f30b7e5a59a57fff3f78d1404e3a1 to your computer and use it in GitHub Desktop.
Save aadmathijssen/fa5f30b7e5a59a57fff3f78d1404e3a1 to your computer and use it in GitHub Desktop.
Magento SUPEE-9767 Checkout Form Key Theme Patch
find -L app/design/frontend -name 'shipping.phtml' -or -name 'billing.phtml' -or -name 'shipping_method.phtml' -or -name 'payment.phtml' -or -name 'addresses.phtml' \
| xargs grep -L formkey \
| xargs perl -i -pe 's/<\/form>/<?php echo \$this->getBlockHtml("formkey") ?>\n<\/form>/g'
find -L skin/frontend -name 'opcheckout.js' \
| xargs grep -L form_key \
| xargs perl -i -pe 's/if \(elements\[i\]\.name=='\''payment\[method\]'\''\) \{/if (elements[i].name=='\''payment[method]'\'' || elements[i].name == '\''form_key'\'') {/g'
find -L js -name 'payment.js' \
| xargs grep -L form_key \
| xargs perl -i -pe 's/if \(elements\[i\]\.name=='\''payment\[method\]'\''\) \{/if (elements[i].name=='\''payment[method]'\'' || elements[i].name == '\''form_key'\'') {/g'
@antoinekociuba
Copy link

Hi @aadmathijssen,

Have added support of addresses.phtml template file + payment.js file:

https://gist.github.com/antoinekociuba/fefd76b72f3ab44503fdcf83ef2dafad

@aadmathijssen
Copy link
Author

Hi @antoinekociuba,

Thanks for the additions!

I updated this gist as well.

@ahofstetter
Copy link

This worked for me, and was very time saving. Thanks!

@dsanderss
Copy link

When running the script in ssh i'll get the following error:
./new.sh: line 11: unexpected EOF while looking for matching `''
./new.sh: line 12: syntax error: unexpected end of file

i hope you can help me because i'm not an expert....

@overrode
Copy link

Fantastic script. thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment