LemonStand Forum: Change Order Status on Receipt Page for Cash - LemonStand Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Change Order Status on Receipt Page for Cash cash on delivery payment method (COD)

#1 User is offline   Lucian 

  • LemonEvangelist
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 74
  • Joined: 06-April 11
  • LocationUSA

Posted 29 March 2012 - 09:27 AM

Long story short, I implemented Cash on Delivery payment method (C.O.D) and the only drawback is that the Payment status is set as New, while it should go to COD Paid status, which is created and assigned properly in the back-end.

I have a custom partial called payment:custom (for some reason this name just show it automatically on the pay page. Probably, other name could work if you add the partial manually):
<h4>COD is for local orders only that have been prearranged.  Payment may be made at time of pickup</h4>
<?= open_form() ?>
	<?= flash_message() ?>
	<ul class="form">
<li><a href="#" class="link-button"  onclick="return $(this).getForm().sendRequest('redirect_to_receipt')" class="link-button" href="#">See Your Receipt</a></li>
</ul>
</form>


On the Ajax tab, under Pay page I have:
function redirect_to_receipt ($controller, $page, $params)
{
    Phpr::$response->redirect(root_url('shop/receipt/'.$params[0], true));
}



What would I need to do on the receipt page so the order can be transitioned automatically for COD orders?
0

#2 User is offline   Aleksey 

  • Co-Founder
  • Group: +Administrators
  • Posts: 4,066
  • Joined: 31-October 09

Posted 01 April 2012 - 02:41 PM

Hi Lucian,

If you have an order object, you can update its status with the following code:

$status = Shop_OrderStatus::create()->find_by_code('cod'); // Assumes that you COD status has the "cod" API code assigned
if ($order->status->code == 'cod')
    Shop_OrderStatusLog::create_record($status->id, $order);


You can try to add this code to your partial.

Thank you

#3 User is offline   Lucian 

  • LemonEvangelist
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 74
  • Joined: 06-April 11
  • LocationUSA

Posted 02 April 2012 - 04:36 AM

Hi Aleksey,
I tried that adding that in payment:custom partial and doesn't do anything. I set the cod API under the payment method.
I also tried adding it on Receipt page and on Pay page with no luck. I appreciate you help us out.

<?= open_form() ?>
	<?= flash_message() ?>
	<ul class="form">
<li><a href="#" class="link-button"  onclick="return $(this).getForm().sendRequest('redirect_to_receipt')" class="link-button" href="#">Confirm</a></li>
</ul>

<? $status = Shop_OrderStatus::create()->find_by_code('cod'); // Assumes that you COD status has the "cod" API code assigned
if ($order->status->code == 'cod')
    Shop_OrderStatusLog::create_record($status->id, $order);
?>
</form>

0

#4 User is offline   Aleksey 

  • Co-Founder
  • Group: +Administrators
  • Posts: 4,066
  • Joined: 31-October 09

Posted 02 April 2012 - 03:24 PM

Hi Lucian,

Quote

I set the cod API under the payment method.


You should assign the API code to the order status, in System/Settings/Order Routes.

I also noticed a logical bug in my code, there should be !== instead of ==

if ($order->status->code !== 'cod')
    Shop_OrderStatusLog::create_record($status->id, $order);


I hope this helps.

Thank you

#5 User is offline   Lucian 

  • LemonEvangelist
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 74
  • Joined: 06-April 11
  • LocationUSA

Posted 03 April 2012 - 06:47 AM

Thank you. This works great now!
0

Share this topic:


Page 1 of 1

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users