Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

E-Commerce Modules /

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

Swipestripe - Stock Inventory Management


Reply


6 Posts   886 Views

Avatar
flipsidenz

Community Member, 49 Posts

4 November 2013 at 9:12pm

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.

Thanks,

Mike

Avatar
flipsidenz

Community Member, 49 Posts

28 November 2013 at 7:09am

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';
         $order->write();

         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;
               $prod->write();
            }
         }
      }
   }

Avatar
frankmullenger

Forum Moderator, 53 Posts

18 December 2013 at 2:29pm

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.

Cheers!
Frank

Avatar
Digitweaks

Community Member, 2 Posts

28 September 2014 at 11:26pm

Any chance to get Stock Level available again ? I feel like one of the main function of a shop is to control the stock level, i been totally disappointed setting up all the shop to realize i got to tweak the code to have a simple function like stock level. I see no documentation about it neither so i'm stuck with a piece of software i can't use on my production site.

Avatar
frankmullenger

Forum Moderator, 53 Posts

3 October 2014 at 4:52pm

Stock management is definitely on the TODO list but can't promise when it will be completed at this stage sorry. Will try and keep you in the loop with progress!

Avatar
Digitweaks

Community Member, 2 Posts

6 October 2014 at 10:59am

Thanks FrankMullenger for your reply, i'm still very enthusiastic to work with SwipeStripe as soon as stock level will be available. Great work BTW !