File Put Content
<?php file_put_contents(diranme(__FILE__).'/data.txt', var_export($cart_contents,true)); ?>