In Magento, somtimes we need to enable the payment-method only for back-end orders.
For this you can create new module in local and overwrite the payment method model in your local folder.
Following are the steps:
Note: You have enabled the method in the configuration for single/differnt store-views.
Create a new module and extend it from the class Mage_Payment_Model_Method_MethodName.
Change the variables:
protected $_canUseInternal = true; // use in admin
protected $_canUseCheckout = false; // use in frontend onepage checkout
protected $_canUseForMultishipping = false; // use in frontend multishippping checkout
$_canUseInternal this variable responsible to show/hide payment method(s) for back-end orders.
$_canUseCheckout this varible is responsible to show/hide payment method(s) for frontend orders in case of onepage checkout.
$_canUseForMultishipping is responsible to show/hide payment method(s) for frontend orders in case of multishippping checkout.
Note that for smaller files it doesn’t matter much. But in case of bigger files it really does.
Lets say we have download links for songs. So the user may want to download one by one, as in this way single file download is faster and user can start listening while other are getting download.
Now suppose our download links provide zipped reports. And those reports will be analyzed later. Another example can be your site provide online courses. When a user going through online tutorial he may download all the resources and assignments. In these cases user may want to download all the files parallel.
Generally we use this type of code to implement download functionality.
Now if you access more than one download link, you may find that when first download is on the process others are not started. After completion of first download second one gets started and so on..
To make all download parallel use this simple trick –
at the top of the method.
What it does?
According to PHP’s session handling, using the default session handler, when a PHP script opens a session it locks it. Subsequent scripts that need to access, it have to wait until the first script is finished with it and unlocks it (which happens automatically at shutdown, or by session_write_close() ). So here session_write_close() simply unlocks the session.
It quite easy. It’s very general we use these operators in our code in many places while matching some important conditions, or in some business logics, password comparisons, etc. But, sometime this make a big problem if we do wrong choice between operator ‘==’ or ‘===’
If your data is from a secure location or already validated, you may not need the strict identical === operator, but if your data is from an outside source (HTTP GET/POST or user entered), you may want to be more precise depending on the situation
1.) == (Equal) for Loose Operations.
2.) === (Identical) for Exact Matches.
For Identical Equal (===) in PHP It removes the Loose evaluations. Identical operator is great whenever you expect both sides of the comparison to have the same type and it will help keep you out of trouble. The output will be more likely what you expect.