How to Create a CSV File with PHP using thephpleague

Posted by on Oct 17, 2017 in Programming | 0 comments

the latest version requires php 7+ but the old 8.x branch can work with a lower version of php so you can download it from: https://github.com/thephpleague/csv/tree/8.2.2 <?php // https://github.com/thephpleague/csv/blob/8.x/examples/writing.php include_once 'shared/csv-8.2.2/autoload.php'; use League\Csv\Writer; // http://csv.thephpleague.com/8.0/bom/ //$writer->setOutputBOM(Writer::BOM_UTF8); //adding the BOM sequence on output $header = ["position" , "team", "played", "goals difference", "points"]; $records = [ [1, "Chelsea", 26, 27, 57], [2, "Arsenal", 26, 22, 56], [3, "Manchester City", 25, 41, 54,], [4, "Liverpool", 26, 34, 53], [5, "Tottenham", 26, 4, 50], [6, "Everton", 25, 11, 45], [7, "Manchester United", 26, 10, 42], ]; $writer = Writer::createFromPath('./file.csv', 'w'); $writer->insertOne($header);...

Read More

Qualities of the Successful Freelancer

Posted by on Oct 7, 2017 in Business | 0 comments

Being a freelancer/subcontractor is becoming the norm nowadays. With that many freelancers it's very convenient for the business to hire people per project and if the project needs more resources to hire even more people. The things i is just like cloud services. This is good for the business because of the unpredictability and the […]

Being a freelancer/subcontractor is becoming the norm nowadays. With that many freelancers it's very convenient for the business to hire people per project and if the project needs more resources to hire even more people. The things i is just like cloud services. This is good for the business because of the unpredictability and the teams can shrink or expand as needed. If you are serious about your freelancing career here are the qualities I believe will help you get and retain your clients. Finding clients The client's won't find themselves you need to dedicate time and effort every single day to look for clients [twitter, job boards etc] that can benefit from your services. Also if they are good fit for you. Even though you can probably service lots of clients you have to be picky about that. a bad client can drain your energy and vice versa. You want clients that respect your processes, pay on time and are understanding when you need to unplug. Not all clients will reply when your contact them and that's OK. You need to keep going without loosing motivation. I have noticed that 1-3 out of 20-30 people will get back to you and out of that 1 may hire you. It is also important how you approach each project. Lots of people including myself I would copy & paste the same content. I wanted to be efficient. It's important to take a minute or two to get an idea what the project is about and ask meaningful questions. If you can even provide some steps that you'd take to complete the project you would be seen as someone who can really do it. What I have done is to check that potential client's website and come up with some suggestions. The idea is to provide value as soon as possible. For some clients I've created a short video recording (up to 1-3 minutes) explaining how I would approach the project. Sometimes I  also turn on my webcam which shows my face in the bottom right corner of the video. The audio + video recording helps the client to determine my level of English (for non-native speakers). Having a picture communicates what person you are. Work ethic Have a great work ethic. If you promise that something will be ready by a given date do everything possible to make that deadline. If you see issues or probables that may cause the deadline to be pushed forward tell the client immediately as soon as you find that out. Waiting for the last possible moment is a really bad idea. You have to be realistic when things are not going well. In such cases...

Read More

How to Completely Uninstall/Remove WooCommerce and Data

Posted by on Aug 10, 2017 in WooCommerce | 0 comments

The complete removal of WooCommerce and its data is not (or should not be) a common thing but it might be useful if you need to go back to previous version of WooCommerce or if just want to start from scratch or if you need to delete some test orders. Here's a video how to do it. […]

The complete removal of WooCommerce and its data is not (or should not be) a common thing but it might be useful if you need to go back to previous version of WooCommerce or if just want to start from scratch or if you need to delete some test orders. Here's a video how to do it. If you deactivate WooCommerce and uninstall like you do with any other WordPress plugin this won’t delete the orders and customer data which makes sense otherwise lots of people would freak out. The only extra step that needs to be done first before you attempt to uninstall WooCommerce is to edit your wp-config.php file and append one line. You need to add this line right after the starting <?php tag. define( 'WC_REMOVE_ALL_DATA', true); To edit that file you will need to use an ftp client (e.g. FileZilla). Do make sure that the quotes are correctly pasted (e.g. single quotes look like single quotes) because if they aren’t this can/will crash your site. If you get an error you can manually delete the quotes around WC_REMOVE_ALL_DATA and type them again and upload the file. Some may wonder why there isn’t a button that can be checked to confirm data deletion. The problem is people don’t read and especially if they are tired or if they don’t know what they are doing they can click on the wrong checkbox and the order data would be lost. Sometimes the user needs to be protected from themselves.   To recap the complete WooCommerce uninstallation steps Add the line in the wp-config.php to confirm that you really want the data removed Deactivate the WooCommerce plugin Uninstall the WooCommerce plugin Maybe reinstall WooCommerce plugin Remove the line from the wp-config.php in case you uninstall the plugin later.   Related https://docs.woocommerce.com/document/installing-uninstalling-woocommerce/   Did your WordPress site ever crash because bad plugins or themes? Next time you should use...

Read More

Decisiveness: Quality 1 of N of Successful Entrepreneurs

Posted by on Aug 9, 2017 in Business, Entrepreneurship | 0 comments

Being decisive is a cool and very important quality. It requires energy and you to face fears of being wrong or even to look stupid. It takes guts to be decisive but there’s no success without decisiveness. It is an important quality not only in business but also in personal life because decisions unstuck you. […]

Being decisive is a cool and very important quality. It requires energy and you to face fears of being wrong or even to look stupid. It takes guts to be decisive but there’s no success without decisiveness. It is an important quality not only in business but also in personal life because decisions unstuck you. You decide which road to take and that makes some of the problems irrelevant and other ones more relevant and that is a good thing. It’s better to solve issues that are right in front of your eyes rather than spend time and energy fixing things that might or might not happen in 1 year. In programming terms this is called premature optimization. It’s good to look ahead but not too far ahead and only when it really makes sense. Many books state that we have a limited pool of energy that we can use for decision per day. Every decision takes some of its contents. With the new day that pool gets replenished. Even micro decisions take mental energy e.g. what clothes/socks to wear, what to eat for breakfast, do you want to drink tea or coffee. To simplify this you can have rules to improve the decision making process. For example: you can prepare your clothes for the next day. You can cereal during the week days and on pancakes on the weekend. Deciding between: coffee or tea. Anytime between 5am & 4pm drink coffee otherwise tea. There will be days when you’ve had to exercise your decision power and lot and at the end of the day you feel drained and deciding what to order for dinner can take minutes to make. That’s normal and is ok. What if I make the wrong decision? I was raised that making mistakes is a wrong thing. Thankfully I was able to change my perception by reading lots of startup/business books. Those books repeatedly mentioned that mistakes are just learning lessons. In the context of startups many decisions/experiments have to be made in order to find a working business model i.e. create something that people want and are willing to pay money for it & are actively looking for a solution. Most of the time it’s better to make a decision early on because you’ll be able to course correct if things don’t work out as expected or you get new information that makes you change course. In one of the business books I remember reading that a CEO mentioned that he/she has changed their mind rather than saying he/she was wrong J.   There are small other cases/exceptions that makes sense to delay making a decision they are called creative procrastination. I like...

Read More

How to Make Some Required Fields Optional on WooCommerce Checkout Page

Posted by on Aug 7, 2017 in WooCommerce | 0 comments

WooCommerce allows you to quickly start an e-commerce store. At some point you may need to customize some of the checkout fields to fit your project requirements. WooCommerce like other well written plugins uses hooks extensively. Those are actions and filters which allow you or your developer to customize the WooCommerce functionality without hacking the […]

WooCommerce allows you to quickly start an e-commerce store. At some point you may need to customize some of the checkout fields to fit your project requirements. WooCommerce like other well written plugins uses hooks extensively. Those are actions and filters which allow you or your developer to customize the WooCommerce functionality without hacking the code. Another benefit of using hooks is that those customizations will survive any WooCommerce updates. Here's a link to the file (next do Save as) : orbisius_quick_fix_wc_ext_opt_co_fields.php <?php /* This code allows you to make some WooCommerce Checkout Fields optional. Blog post http://orbisius.com/link/3710 Author: Svetoslav Marinov (Slavi) Author URI: http://orbisius.com */ /* Installation 1. Paste the code below in your functions.php OR create an mu-plugin in wp-content/mu-plugins/orbisius_quick_fix_wc_ext_opt_co_fields.php 2. Define which fields you want optional by putting this in your wp-config.php You can see the fields on the blog post about this fix at http://orbisius.com/link/3710 define('ORBISIUS_QUICK_FIX_WOO_OPTIONAL_CHECKOUT_FIELDS', 'first_name,last_name' ); 3. If you want a customizaiton ($) contact me. */ add_filter( 'woocommerce_checkout_fields', 'orbisius_quick_fix_wc_ext_opt_co_fields_make_optional_fields', 25); add_filter( 'woocommerce_billing_fields', 'orbisius_quick_fix_wc_ext_opt_co_fields_make_optional_fields', 25); add_filter( 'woocommerce_default_address_fields', 'orbisius_quick_fix_wc_ext_opt_co_fields_make_optional_fields', 25); /** * This function does the heavy lifting to make fields optional. * @param array $fields * @return array * @copyright (c) 2017 Slavi Marinov, http://orbisius.com */ function orbisius_quick_fix_wc_ext_opt_co_fields_make_optional_fields($fields) { static $optional_fields = null; // Don't know what to process so let's get out of here. if (!defined('ORBISIUS_QUICK_FIX_WOO_OPTIONAL_CHECKOUT_FIELDS')) { return $fields; } if (is_null($optional_fields)) { $optional_fields = preg_split('#\s*[\,\;\|\r\n]+\s*#si', ORBISIUS_QUICK_FIX_WOO_OPTIONAL_CHECKOUT_FIELDS ); $optional_fields = array_unique($optional_fields); $optional_fields = array_filter($optional_fields); } // Nothing to process so let's get out of here. if (empty($optional_fields)) { return $fields; } foreach ($optional_fields as $field_key) { if (isset($fields[$field_key])) { $fields[$field_key]['required'] = false; } if (isset($fields['shipping'][$field_key])) { $fields[$field_key]['shipping']['required'] = false; } if (isset($fields['billing'][$field_key])) { $fields[$field_key]['billing']['required'] = false; } // do we have fields that don't have a prefix? $no_prefix_key = $field_key; $no_prefix_key = preg_replace( '#(billing|shipping)_#si', '', $no_prefix_key); if (isset($fields[$no_prefix_key])) { $fields[$no_prefix_key]['required'] = false; } if (isset($fields['shipping'][$no_prefix_key])) { $fields[$no_prefix_key]['shipping']['required'] = false; } if (isset($fields['billing'][$no_prefix_key])) { $fields[$no_prefix_key]['billing']['required'] = false; } } return $fields; } Here are all of the Shipping & Billing fields from all the filters. array ( 'first_name' => array ( 'label' => 'First name', 'required' => false, 'class' => array ( 0 => 'form-row-first', ), 'autocomplete' => 'given-name', 'autofocus' => true, 'priority' => 10, ), 'last_name' => array ( 'label' => 'Last name', 'required' => false, 'class' => array ( 0 => 'form-row-last', ), 'autocomplete' => 'family-name', 'priority' => 20, ), 'company' => array ( 'label' => 'Company name', 'class' => array ( 0 => 'form-row-wide', ), 'autocomplete' => 'organization', 'priority' => 30, ), 'country' => array ( 'type' => 'country', 'label' => 'Country', 'required' => true, 'class' => array ( 0 => 'form-row-wide', 1 => 'address-field', 2 => 'update_totals_on_change', ), 'autocomplete' =>...

Read More
We're working on a free WordPress migration service called wpmove.org Check the site to learn more ;)