Before reading this article it is advised to read “How to run Magento in WordPress“, as it could help you overcome some basic problems that might emerge. This snippet shows you how to get Magento categories and show them in WordPress so you can use them as a menu. Copy following snippet into your WordPress [...]
Many developers like combining Magento and WordPress, and there is many more out there that would like to. All snippets showing how to grab data from Magento don’t warn you that there is the function in Magento core that has the same name as WordPress function for translation “__()”. For this reason it is not [...]
So, let’s say you are about to launch your new website. You have written it and tested in localhost, and it is time to go live! Only… not in the public yet. You want to adjust some more things, and check if your website is working correctly, and you don’t want users to see errors [...]
In: PHP
29 Sep 2010With PHP function similar_text(), you can offer your users a Google like “Did you mean” suggestion to a misspelled word. All you need is a word by word comparison using a PHP function similar_text. See and use snippet below in order to find most similar word to the one you choose. 1 2 3 4 [...]
When making customization for our WordPress theme, often we need to check if user is logged in. It is a simple task when using a WordPress function is_user_logged_in(). Here is a simple snippet that shows you how to check if user is logged in or not. 1 2 if(is_user_logged_in()) echo ‘You are logged in.’; else [...]
In: PHP
7 Sep 2010When there is a need for converting currency, you can use Google calculator API. It is easy to get value, and after you get it – all you have to do is parse it. Copy this simple snippet in order to make currency converter work on your website. 1 2 3 4 5 6 7 [...]
In: PHP
6 Sep 2010Very often we have a situation where we need to change users address back, from where he came. It is mostly used on pages where user should login or register. To get him back we could send previous URL as parameter in login or registration form. Add this code inside your form to send your [...]
In: PHP
31 Aug 2010In order to format output, sometimes you need to add leading characters. PHP has a str_pad function that lets add leading or trailing characters to achieve string length. In following snippet, you can see simple example of usage. 1 2 3 4 5 6 function add_leading_zeros($input, $str_length) { return str_pad($input, $str_length, ’0′, STR_PAD_LEFT); } [...]