I have a problem with the order creation on Magento via direct PHP
I use Magento version 184.108.40.206
This is the code I made:
<?php require_once '../../app/Mage.php'; Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID); $resource = Mage::getSingleton('core/resource'); $readConnection = $resource->getConnection('core_read'); $writeConnection = $resource->getConnection('core_write'); $_customer = Mage::getModel('customer/customer')->load(1); $firstName = $_customer->getFirstname(); //get customers first name $lastName = $_customer->getLastname(); //get customers last name $customerAddressId = $_customer->getDefaultBilling(); //get default billing address from session $address = Mage::getModel('customer/address')->load($customerAddressId); $street = $address->getStreet(); $city = $address->getCity(); $postcode = $address->getPostcode(); $phoneNumber = $address->getTelephone(); $countryId = $address->getCountryId(); $regionId = $address->getRegionId(); $quote = Mage::getModel('sales/quote')->setStoreId(1); $quote->assignCustomer($_customer); $addressData = array( 'firstname' => $firstName, 'lastname' => $lastName, 'street' => $street, 'city' => $city, 'postcode' => $postcode, 'telephone' => $phoneNumber, 'country_id' => $countryId, 'region_id' => $regionId ); $product = Mage::getModel('catalog/product')->load(5525); $quoteItem = $quote->addProduct($product, 1); $quote->save(); $quote->getBillingAddress()->addData($addressData); $shippingAddress = $quote->getShippingAddress()->addData($addressData); $shippingAddress->setCollectShippingRates(true)->collectShippingRates()->setShippingMethod('freeshipping_freeshipping')->setPaymentMethod('banktransfer'); $quote->getPayment()->importData(array('method' => 'banktransfer')); $quote->collectTotals()->save();
On Magento, I have already created a customer with ID 1 who has both the billing address and the shipping address
There is also a product with id 5525
Free shipping and bank transfer payment methods are enabled
The store is associated with the Italian state with a percentage tax of 22%
When I execute this code I noticed that in the table "sales_flat_quote_item" some wrong data are saved
Practically the fields "tax_amount", "base_tax_amount", "price_incl_tax", "base_price_incl_tax", "row_total_incl_tax", "base_row_total_incl_tax" are saved with the value "0"
Instead the "price","row_total","base_row_total" field are correct and the "tax_percent" field is correctly "22"
These are the screens of the table "sales_flat_quote_item":
If, on the other hand, I create an order from the Magento frontend, in the "sales_flat_quote_item" table, the data is saved correctly and so the order is correct
I have this problem since I updated the version of Magento from 220.127.116.11 to 18.104.22.168
Can you figure out what the problem maybe?