Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#901 2020-12-20 19:22:03

pexman
Member
Registered: 2016-02-27
Posts: 63

Re: yab_shop (simple textpattern shop with paypal support)

<txp:yab_shop_add /> quantity

My shop is now working and I have new wishes.

It would be nice if the number of items for sale could be indicated. If a unique item is offered, it makes no sense to enter more than 1 in the order field. In addition, after an order, the remaining number would have to be automatically reduced or, if the order was not completed, added again.

Maybe the topic has existed before, but I couldn’t find anything through the search.

Last edited by pexman (2020-12-20 19:22:52)

Offline

#902 2020-12-20 19:47:48

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,447
Website GitHub

Re: yab_shop (simple textpattern shop with paypal support)

Not quite sure I understand your request, sorry. Are you saying:

  1. You want a tag to allow people to specify the quantity of things on the article page near the ‘Buy’ button?
  2. You want to remove the quantity from the checkout so people cannot alter the quantity for some (all?) products?

For the “business logic” of altering inventory, that is not handled by the plugin natively. I would approach it like this:

a) Set a custom field to hold the ‘inventory’ value for each product (article).
b) Display this on the product page as an ‘Available to buy’ value.
c) There’s a plugin (unreleased and I don’t know if it still works with PayPal’s latest API) called smd_ipn that listens for successful transactions from PayPal. It then ‘wakes up’ and you can basically get it to do anything you want. Send off confirmation emails, log things, register orders, insert stuff in the database or, in your case, update the ‘inventory’ value in that custom field for the item that has just been bought.

You are more than welcome to have a copy of this plugin (just let me know) but as I say, I have no idea if it still works.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#903 2020-12-20 21:44:26

pexman
Member
Registered: 2016-02-27
Posts: 63

Re: yab_shop (simple textpattern shop with paypal support)

Yes, very professional, I didn’t expect anything else either :) I now have the following solution. On a form, I’ll check the rearranged custom_field named Item_Number to see if it’s empty.

Because I can’t sell all items in all quantities, I check the custom_field with the name Price (as entered in yab_shop.conf). If it is empty no output is given. If there is a price then starts the check if custom_field named Item_Number has a value. If no value is displayed, it indicates that the item is sold out.

I took the content out of the term <txp: yab_shop_add />. You can easily find the string by looking at your site’s source, something with <form> … yab_shop…<form>

Here is my code:

<a name="info"><h2><txp:title /></h2></a>
   <p class="footnote"><txp:text item="posted" /> 
<time datetime="<txp:posted format='iso8601' />"><txp:posted /></time></p>
<txp:body />
<br>
<txp:variable name="has-price"><txp:custom_field name="Preis" /></txp:variable>
<txp:variable name="has-anzahl"><txp:custom_field name="Anzahl" /></txp:variable>

 <!-- ############# check and output ############### -->

<txp:if_variable name="has-anzahl" value=""><txp:variable name="mehr"></txp:variable>
<txp:else />
<txp:variable name="mehr"><form method="post" action="https://arteurope.de/shop/Geist#yab-shop-form-582" id="yab-shop-form-582"><p class="yab-add"><input type="number"  name="qty" value="1" min="1" max="<txp:variable name="has-anzahl" />" /><input name="add" class="submit" type="submit" value="Bestellung" /></p></form></txp:variable></txp:if_variable>

<txp:if_variable name="has-price" value=""><txp:variable name="shopy"><hr width="240px"></txp:variable>
<txp:else />
<txp:if_variable name="mehr" value=""><txp:variable name="shopy"><p><strong>Nicht mehr erhältlich!</strong></p ></txp:variable>
<txp:else />
<txp:variable name="shopy"><big><txp:yab_shop_price/></big><br><br><txp:variable name="mehr" /><txp:yab_shop_cart ><txp:yab_shop_cart_items /><txp:image id="306" /><txp:yab_shop_cart_link  label='zur Kasse' /></txp:yab_shop_cart></txp:variable></txp:if_variable></txp:if_variable>

 <!-- ############# output ############### -->
<txp:variable name="shopy" />

<br>

<txp:text item="author" /> 
<span ><txp:author link="1" this_section="1" /></span><br>
  <txp:if_article_category>
                    <strong><i><txp:text item="categories" /></i></strong>
                    <span>
                        <i>
                            <txp:category1 title="1" link="1" this_section="1"/>
                            <txp:if_article_category number="1">
                                <txp:if_article_category number="2">, </txp:if_article_category>
                            </txp:if_article_category>
                            <txp:category2 title="1" link="1" this_section="1"/>
                        </i>
                    </span>
                </txp:if_article_category>

But how can I automaicly subtract a sold item from the Item_Number field? And how can it be added back if the customer cancels the process?

Last edited by pexman (2020-12-20 22:34:25)

Offline

#904 2020-12-20 21:58:20

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,447
Website GitHub

Re: yab_shop (simple textpattern shop with paypal support)

pexman wrote #327708:

But how can I automaicly subtract a sold item from the Item_Number field? And how can it be added back if the customer cancels the process?

You can’t (shouldn’t) do it client-side when people place things in their basket. The only reliable way is to intercept the “success” or “cancelled” transaction from the payment gateway and make any ‘business’ database alterations then.

Since yab_shop only supports PayPal at present, you need something that hooks into the PayPal loop. They use IPN which can be told to pass the transaction result (pass/fail) to a web link. Then, a plugin listening at that endpoint (in this case, I wrote smd_ipn to do the job) can intercept the call and take action to decrement the stock counter.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#905 2020-12-20 22:37:58

pexman
Member
Registered: 2016-02-27
Posts: 63

Re: yab_shop (simple textpattern shop with paypal support)

Okay, you are definitivly right. A never ending story, but for today it is enough, thank you Mister Bloke for your attention and intuition.

Offline

#906 2021-03-25 07:26:16

peterj
Member
From: Melbourne, Australia
Registered: 2005-06-02
Posts: 99

Re: yab_shop (simple textpattern shop with paypal support)

Having a play with this for the first time. Very exciting.
A couple of issues spotted with the cart – may just be me as it’s early days:
- the cart throws “Notice: Trying to access array offset on value of type null” warning in list pages with debug on, PHP 7.4.
- cart container tag duplicates content in 7.4 & 7.3. It’s like the container tag is outputting like a single tag too. This is what I see for:

 <txp:yab_shop_cart>
		  <txp:yab_shop_cart_items />
		  <txp:yab_shop_cart_quantity />
		  <txp:yab_shop_cart_subtotal />
		  <txp:yab_shop_cart_link />
	</txp:yab_shop_cart>

output: Item 1 Price: $500.00 Quantity: 2

Subtotal: $1,000.00Proceed to Checkout Quantity: 1
Subtotal: 1,000.00
Proceed to Checkout

Offline

#907 2021-03-25 07:52:36

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,447
Website GitHub

Re: yab_shop (simple textpattern shop with paypal support)

The duplicate cart is documented somewhere. I forget why it happens now but it’s either to do with a pref being set that automatically adds the cart, or that you need to add (or not add, haha) a tag to your page to tell it to do (or not do) something.

Sorry that’s vague. It’s been a while since I used this plugin and I’m in a hurry so don’t have time to search for the answer in this thread or in the docs or look at one of my installs that uses it.

The warning about the array offset is fixable. If nobody else has jumped in before I get a chance later, I can advise on the fix. You’re using trenc’s official plugin and not my heavily modified fork, right?


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#908 2021-03-28 23:39:35

peterj
Member
From: Melbourne, Australia
Registered: 2005-06-02
Posts: 99

Re: yab_shop (simple textpattern shop with paypal support)

HI bloke,
thanks for answering. I’ll do a search for the duplicates issue.
Yes I’m using the group of 3 plugins by T Schmucker, v 0.8.5. I hadn’t realised you’d forked it – will have a look for that too.

Offline

#909 2022-08-15 14:31:32

brainseller
New Member
From: Nürnberg, Germany
Registered: 2011-11-08
Posts: 3
Website

Re: yab_shop (simple textpattern shop with paypal support)

I was so happy to see the plugin still working, but then I noticed a strange error during checkout, only on Safari on macOS and iOS.
The order is placed, mails are delivered, but the response page throws an error.

„cannot parse response“ (NSURLErrorDomain:-1017)

After trying everything on my test site I visited the official demo shop and there it happens too. Anyone else noticed that? Is there any workaround?

Offline

#910 2022-08-15 17:11:45

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,447
Website GitHub

Re: yab_shop (simple textpattern shop with paypal support)

Hi brainseller. My best guess is an API change or something slightly misconfigured in what is returned from PayPal.

Not sure why only Safari would be affected so it would be interesting to gauge feedback from shops in the wild. I have one site running a modified version of the plugin so I can perhaps run some tests there.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#911 2022-08-15 17:19:30

brainseller
New Member
From: Nürnberg, Germany
Registered: 2011-11-08
Posts: 3
Website

Re: yab_shop (simple textpattern shop with paypal support)

Hi Bloke,
thank you for your answer. At first it would be interesting if it affects other people or only me. I cold think of only one plugin I have installed on iPhone and desktop Safari and so I deactivated it. But still getting the same issue. It can’t be because of PayPal, because I used Pay on delivery on my site and in the demo shop. Where can I find your modified version. I would gladly run some tests.

Offline

Board footer

Powered by FluxBB