I am using a payment module with Prestashop 1.6, everything was working fine until an upgrade happened. The payment server return the validation data to an url like "http://..../validation.php".
This file tries to get the order using the cart id that is returned by the server and obviously cant find it, hence the cart is not emptied and the order not created.
I added logs into that file to see what is received. The CartID (data['reference']) is correct.
writeMessage("Trying to get the order id using the cart:".$data['reference']);
writeMessage(Order::getOrderByCartId((int)($data['reference'])));
if ($id_order = intval(Order::getOrderByCartId((int)($data['reference']))))
{
writeMessage("Got the order by cart id.");
writeMessage("Got the order by cart id:".$id_order);
$order = new Order($id_order);
...
I am wondering if the call to Order::getOrderByCartId is correct. Is it the right way to call this function?
Any idea?
I can answer my question. The issue was not on the call to getOrderByCartId as it is normal that at this moment the order is not created yet.
The issue is actually on the validation function of the module, second part of the if.
$module->validateOrder(intval($data['reference']), $orderStatus, $amount, $module->displayName, $orderMessage, NULL, $id_currency, true, $customer->secure_key);
Related
i'm dealing with a problem, I need to change the carrier if the cart amount it > 500 , so , I'm hooking actionCartSave and checking the amount , but , when I do
$cart->id_carrier=(int)$carrier_id;
$cart->update();
The ajax stops responding , need to reload the page to see if a product has been added to the cart, but if i remove the $cart->update() , the carrier does not get updated. How can i solve this?
Maybe you are running into a loop. when you call update, the hook actionCartSave gets called again.
What you need to do is avoid updating the cart if the cart carrier is the same one as in your result
if ((int)$cart->id_carrier !== (int)$carrier_id) {
$cart->id_carrier = (int)$carrier_id;
$cart->update();
}
That way, you will avoid the infinite loop
Another (better) solution would be to use $cart->save(); because it doesn't call actionCartSave
I created two group one is A and other is B . i want there multiple option as each have different prices as acording to customer group i have some code but it does not run properly it give a message as "Call to undefined method Cart\Customer::getCustomerGroupId() in C:\xampp\htdocs\postal\vqmod\vqcache\vq2-catalog_model_catalog_product.php on line 340".
the code is in vqmod xml file -enter code here
problem is there i can not know how to definde customer group id and this code is running in old version perfectly
the code is attach in link -- product-option by download-customer group
please check this and send me how to define and fix the bug.
the code run proper before login- wen i login then give error message.
I suggest to modify system\library\cart\customer.php to:
/create a function/
public function getCustomerGroupId() {
return $this->customer_group_id;
}
My problem is, that second parameter in plgVmOnUpdateOrderPayment event is actually old status code before change.
Did anybody knows, how to get new status letter after changing order status via e.g. paypal plugin or in administration?
Aleš Pázner, yes the second parameter is always the old order status.
But you can use this piece of code:
function plgVmOnUpdateOrderPayment($virtuemart_order,$old_status) {
// getting the new status
// $virtuemart_order->order_status
return;
}
Source: Plugin event methods in Virtuemart for order status
I'm trying to change the order of the steps in the magento onepage checkout. What I need to do is to move the Review step before the Payment selection.
I've looked on the internet for a solution but everything I found was to change the order in app/code/core/Mage/Checkout/Block/Onepage/Abstract.php
I've tried it, but nothing changed.
What I did was creating a file inside app/code/local/Mage/Checkout/Block/Onepage/Abstract.phpand inside this file I've changed the line 208 in:
protected function _getStepCodes()
{
return array('login', 'billing', 'shipping', 'shipping_method', 'review', 'payment');
}
what am I missing here?
(I'm using Magento 1.9.1.1)
Don't change the php code.Keep it as it is.I think let the php do his work. But show the thing you want. Go to app->design->frontend->[package-name]->default->template->checkout->onepage->progress.phtml and open and change the order accordingly. Have fun.
I am currently making a module that requires me to take an order object and make it reorder itself.. thus, creating a new order in the backend with the exact same items and credentials.
This is the code that i have thus far… it doesn’t seem to reorder the item or create and add another backend order.
$personsOrder = Mage::getModel(’sales/order’);
$personsOrder->loadByIncrementId($order[’model_order_id’]);
$order_model = Mage::getSingleton(’adminhtml/sales_order_create’);
$personsOrder->setReordered(true);
$order_model->initFromOrder($personsOrder);
/*
$order_model->save();
$order_model->place();
$order_model->sendNewOrderEmail();
*/
Any help is greatly appreciated!!
$orderId= $YOUR_ORDER_NUMBER;
$personsOrder = Mage::getModel('sales/order')->load($orderId);
$order_model = Mage::getSingleton('adminhtml/sales_order_create');
$personsOrder->setReordered(true);
$order_model->initFromOrder($personsOrder);
$order_model->createOrder();
My first thought is that you should be using $order->getIncrementId() on line 2 rather than $order['model_order_id'], but I'm not sure where you're getting $order from in the first place. Have you checked that $order['model_order_id'] is actually returning a valid increment ID? I don't see model_order_id as a field in the database anywhere...
I'd be suggesting that you getting your IDE and XDebug working so that you can inspect the objects as you work with them and understand what's going on.
Cheers,
JD
If the order that you have placed the first time around is also created through coding and not from store front then you need to make sure that you have added an entry in the sales_flat_quote_item table. Otherwise that order cannot be reordered. So make sure it's not the case with your order creation.