when i submit an edited order in which the reward points awarded is negative (because the new processed order is less than the original), in the reward history one of the entries is pushed forward 12 hours ahead of the most recent entry

this isn't causing any bad effects to the total reward points as the value is being calculated correctly

there's really nothing my edit order module could be doing that does this, to edit the order the module just does the exact same thing as what Reorder does but it also creates a new session which stores the previous order's item's, their qty, the date the order was made and it's increment id, how the points are calculated is that when they are normally calculated, there's a check for this session, if it's exists it gets the Base Grand Total, puts that though $this->getReward()->getRateToPoints()->calculateToPoints() and subtracts that from the points delta

when we process the order in the checkout, it just creates a new order but the transaction id is the same as the previous order, since internet sales looks at this transaction id they'll know which order to edit, the old order will be canceled during the next run of the synchronization scripts

given all of that, at no time do i ever do anything with the reward history and it's not always the order your editing who's reward history entry i pushed up, i went and edited order 100000040 but 100000042 was pushed up

NOTE: i should also point out that the orders are not storing the same transaction id at this time as i am waiting on sample xml to compare to the request/response xml from the payment gateway, so there is no way that an order once process is tied to another order in any way

The following code is taken from Enterprise_Reward_Model_Action_OrderExtra::getPoints, it is places between $pointsDelta = $this->getReward()->getRateToPoints()->calculateToPoints((float)$monetaryAmount); and return $pointsDelta;

$editOrder = Mage::getModel('core/session')->getData('editorder');

        $readConnection = Mage::getSingleton('core/resource')->getConnection('core_read');
        $result = $readConnection->fetchAll("
                SELECT sfo.entity_id FROM sales_flat_order AS sfo
                    WHERE sfo.increment_id = ?
                LIMIT 1
        $order = Mage::getModel('sales/order')->load($result[0]['entity_id']);
        $orderData = $order->getData();
        $previousOrderMonetaryAmount = (($orderData['base_grand_total'] - $orderData['base_shipping_amount']) - $orderData['base_tax_amount']);

        $pointsDelta = $pointsDelta - $this->getReward()->getRateToPoints()->calculateToPoints((float)$previousOrderMonetaryAmount);

enter image description here

above is a snapshot of what's happening, the top shows what the reward history was before en order was edited and processed, the bottom is what happens after (for #100000049 nothing happened so i had to do it again yo get the glitch showing up)

the items in #100000044 are completely different to order #100000048, order #100000046 is missing cause when the points delta is 0 (meaning no points will be added/subtracted) it doesn't show (which is good)

all the order with a negative values are processed edited orders of those which had positive values but had some items removed during the edit reducing the cart total (in the gateway, this would then refund the customer so it makes sense that they should not be allowed to have the points that they was refunded for)

  • Without code, this is not debuggable. Mar 14, 2013 at 7:44
  • 12h? I'd say wrong timezone handling. Make sure you are taking timezone in consideration. Don't forget, Magento always saves dates using UTC & converting them to your timezone when displaying. Mar 14, 2013 at 9:50
  • @FabianBlechschmidt i've added the code that changes the points delta if the order is being edited, i have not touched how reward points are applied to the total
    – Memor-X
    Mar 14, 2013 at 21:25
  • @PaulGrigoruta look at it now it's actually 11 hours which would make sense if it was a timezone conversion problem (i'm +11) however it doesn't affect the entry just made, it affects a previous entry which had the correct time
    – Memor-X
    Mar 14, 2013 at 22:31

1 Answer 1


The problem is to do with Magento itself, by forcing a clean build of Magento to always have a negative amount in the order using $pointsDelta = $pointsDelta - 100000 results in the exact same problem, no idea if Magento will consider it a bug though since the only way to have discovered it is via customization of Magento but I'll report it nonetheless.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.