Shipment plugin, which method before storing the order?

Started by Kuubs, November 24, 2023, 22:02:45 PM

Previous topic - Next topic

Kuubs

I have a custom shipment plugin which saves order data. Now I want to check if that is filled in before i store the order.. But plgVmConfirmedOrder the order is already stored. How can I prevent the order save if a specific data is not set??

Kuubs

Does nobody knows this?

I dislike the lack of documentation, and the unwillingness for other experienced developers to help other people. This should be an easy answer for the peolpe that know Virtuemart. But nobody knows??

hazael

For example, I totally don't understand what you wrote, so I don't even bother with this post  ;D

Kuubs

Quote from: hazael on November 27, 2023, 10:48:09 AM
For example, I totally don't understand what you wrote, so I don't even bother with this post  ;D

What do you mean you don't know what I wrote?

When an order is made there are probably a couple of methods that are being run (validating etc) before actually storing the order. So which method is that? That is the only thing I ask? What's so hard about that?

I want to check whether or not an order has all the requirements I need for my shipment. When a field is empty it should redirect back to the cart page and show an error.

Jumbo!

VirtueMart triggers the "plgVmConfirmedOrder" event after saving the order in the "Pending" state. It passes two arguments to the event. The first is in the cart object, and the second is the order object. Therefore, you can not stop order creation when this event is called.

To check if the cart object has valid data and trigger an error before the order is saved, you must use the "plgVmOnCheckoutCheckDataShipment" event.

Example:

<?php

  
public function plgVmOnCheckoutCheckDataShipment($cart) {
    
// Do data validations here
    
$isValid false;

    
// If data is invalid
    
if (!$isValid) {
      
// Show the error message.
      
JFactory::getApplication()->enqueueMessage('Please fill up the required data.''error');

      
// Return false to stop order processing
      
return false;
    }

    
// Return true to allow order processing
    
return true;
  }

Kuubs

Quote from: Jumbo! on November 28, 2023, 07:05:26 AM
VirtueMart triggers the "plgVmConfirmedOrder" event after saving the order in the "Pending" state. It passes two arguments to the event. The first is in the cart object, and the second is the order object. Therefore, you can not stop order creation when this event is called.

To check if the cart object has valid data and trigger an error before the order is saved, you must use the "plgVmOnCheckoutCheckDataShipment" event.

Example:

<?php

  
public function plgVmOnCheckoutCheckDataShipment($cart) {
    
// Do data validations here
    
$isValid false;

    
// If data is invalid
    
if (!$isValid) {
      
// Show the error message.
      
JFactory::getApplication()->enqueueMessage('Please fill up the required data.''error');

      
// Return false to stop order processing
      
return false;
    }

    
// Return true to allow order processing
    
return true;
  }


Thank you! This is great advice and help. Thanks again.