cancel
Showing results for 
Search instead for 
Did you mean: 

How to solve Magento 1.9.2.3 require_once Error?

How to solve Magento 1.9.2.3 require_once Error?

I have Custom PHP script about shipping estimation, 

 

<?php
ob_start();
require_once(__DIR__ . '/app/Mage.php');
umask(0);
ini_set('display_errors',true); 
ini_set('memory_limit', '1024M');
Mage::app()->loadArea('frontend');


function getShippingEstimate($productId,$productQty,$countryId,$postcode ) {

    // $quote = Mage::getModel('sales/quote')->setStoreId(Mage::app()->getStore('default')->getId());
	$quote = Mage::getModel('sales/quote')->setStoreId(Mage::app()->getStore('english')->getId());
    $_product = Mage::getModel('catalog/product')->load($productId);

    $_product->getStockItem()->setUseConfigManageStock(false);
    $_product->getStockItem()->setManageStock(false);

    $quote->addProduct($_product, $productQty);
    $quote->getShippingAddress()->setCountryId($countryId)->setPostcode($postcode); 
    $quote->getShippingAddress()->collectTotals();
    $quote->getShippingAddress()->setCollectShippingRates(true);
    $quote->getShippingAddress()->collectShippingRates();

    $_rates = $quote->getShippingAddress()->getShippingRatesCollection();

    $shippingRates = array();
    foreach ($_rates as $_rate):
            if($_rate->getPrice() > 0) {
                $shippingRates[] =  array("Title" => $_rate->getMethodTitle(), "Price" => $_rate->getPrice());
            }
    endforeach;

    return $shippingRates;

}
echo "<pre>";
//product id, quantity, country, postcode
print_r(getShippingEstimate('14419','1',"IN","642001"));

echo "</pre>";




?>

 

 

If i run above script in the location => root_folder/sp_cost.php it should be working, after i moved to my project folder like => root_folder/my_folder/sp_cost.php I get the following  error, 

 

PHP Warning: require_once(../../app/Mage.php): failed to open stream: No such file or directory in /home/abc/public_html/kolupadi_extension_order/sp_cost.php on line 4

PHP Fatal error: require_once(): Failed opening required '../../app/Mage.php' (include_path='.:/opt/cpanel/ea-php70/root/usr/share/pear') in /home/abc/public_html/kolupadi_extension_order/sp_cost.php on line 4

 

How to solve the require_once error?

 

FYI => I am using Multi-Website