Jump to:

2084 Posts in 1005 Topics by 453 members

E-Commerce Modules

SilverStripe Forums » E-Commerce Modules » Swipestripe - Stock Inventory Management

Discuss about the various e-commerce modules available:
Ecommerce, SS Shop, SilverCart and SwipeStripe
Alternatively, have a look the shared mailinglist.

Moderators: martimiz, Nicolaas, Sean, frankmullenger, biapar, Willr, Ingo, Jedateach, swaiba, simon_w

Page: 1
Go to End
Author Topic: 686 Views
  • flipsidenz
    Community Member
    49 Posts

    Swipestripe - Stock Inventory Management Link to this post

    Hi there,

    I have started to work with a SS 3.1 / Swipestripe install and I am wondering whether there is a pre-existing inventory management module for swipestripe? I'm not after anything fancy, simply a stock level which decrements with each purchase of a product is made - and perhaps the ability to set a product to sold out/out of stock when a product's stock level hits zero.

    Please let me know if you can help.



  • flipsidenz
    Community Member
    49 Posts

    Re: Swipestripe - Stock Inventory Management Link to this post

    Surprised there was no ideas for such a common issue. However...

    To resolve this I created my own field in the product dataobject called stock. Then, to decrement the product stock levels upon successful purchase of said product, I simply extended Payment_Extension and added the function "onAfterWrite" to my dataextension. Within onAfterWrite, I applied straight forward logic to decrement each products stock level:

    function onAfterWrite() {

          $order = $this->owner->Order();

          if ($order && $order->exists()) {
             $order->PaymentStatus = ($order->getPaid()) ? 'Paid' : 'Unpaid';

             if($order->PaymentStatus == 'Paid'){

                $items = $order->Items();

                foreach($items as $item){
                   $qty = $item->Quantity;
                   $prodId = $item->ProductID;

                   $prod = Product::get()->byID($prodId);
                   $prod->Stock = $prod->Stock - $qty;

  • frankmullenger
    Forum Moderator
    51 Posts

    Re: Swipestripe - Stock Inventory Management Link to this post

    Really pleased that you could achieve this without too much trouble! That is the intention with SwipeStripe - a module that is easy to extend and customise for your needs. If you ever make this work into a module please let me know.

    There was a stock management feature of the previous version however it was stripped out and hasn't been pulled into it's own module yet, it worked on the basis that stock reduced once an item was in a cart but I think a lot of people would like the approach you have used.


Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.