Getting data from Community Store

Permalink
I'm looking to see if I can pull the quantity of a product purchased so I can manually manipulate user data. Is there a way to get this data in php after a successful transaction?

GeeEM
 
GeeEM replied on at Permalink Reply
GeeEM
I've located packages\community_store\single_pages\checkout\complete.php which sounds like it might work. In it, I see:

/*
 *  The Order object is loaded should we wish to place receipt details here.
 *  Example:
 *  echo $order->getTaxTotal()
 *  echo $order->getShippingTotal()
 *  echo $order->getTotal()
 *  
 *  $orderItems = $order->getOrderItems();
 *  foreach($orderItems as $item){
 *      echo $item->getProductName();
 *      echo $item->getQty();
 *      echo $item->getPricePaid();
 *  }
 * 
 */


Would the best way to do this to be to put in something like:

if($item->getProductName() == "Item wanted") {
    // Code to add to user attribute
}


?
jero replied on at Permalink Reply
jero
I think a good start would be to look athttps://github.com/concrete5-community-store/community_store/wiki/Ev...

and then add some code to hook in to the on_community_store_payment_complete event.

You'll probably need to add a little custom package, and add the code into the package controller's on_start() method.The WIKI page links to an example package you can modify as you see fit.
mesuva replied on at Permalink Reply
mesuva
As Jero has mentioned you may be able to use Events, to develop custom behaviour when orders are placed. Basic doco is here:
https://concrete5-community-store.github.io/community_store/develope...
(the work very similar to other concrete5 events that are triggered)

There's also a new RESTful API for Community Store, which would allow you fetch data about all/any order externally: https://github.com/concrete5-community-store/community_store_api...