Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#331 2009-06-08 16:38:41

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,439
Website GitHub

Re: yab_shop (simple textpattern shop with paypal support)

trenc

Many thanks for the modded yab_shop_special_promo(). I originally had properties governing the different product models but I’ve ditched that and gone with one article per product. Keeps things simpler and allows me to go a stage further with your mod. For info:

1) Each product employs an optional custom field called Discount

2) If a discount structure is valid for a product, sed_pcf sets up discounts per tier, e.g. Silver(d='10')|Gold(d='15')|Platinum(d='20')

3) If we are viewing an item in the shop, then I do the logic:

<txp:smd_switch item='<txp:ign_user_info type="name" />'>

<txp:smd_case value="client1" />
<txp:smd_case value="client2" />
<txp:smd_case value="client4">
<txp:variable name="client_discount_name" value="Silver" />
</txp:smd_case>

<txp:smd_case value="client3">
<txp:variable name="client_discount_name" value="Gold" />
</txp:smd_case>

</txp:smd_switch>

<txp:variable name="client_discount" value='<txp:sed_pcf_get_value custom="discount" section=''<txp:variable name="client_discount_name" />'' variable="d" default="0" />' />

So that sets up a client_discount_name that I can refer to and display on-screen. It also matches one of the sections in sed_pcf so I can read out the discount that applies to this product, depending on the client’s tier.

4) After that, a call to <txp:yab_special_promo discount='<txp:variable name="client_discount" />' /> is all that is required to register the discount for the current product. Upon visiting the checkout, the per-product discounts for that client’s products in their cart are automatically applied!

I do various bits of trickery as I mentioned in an earlier post to check if the value of the discount is non-zero so I can display things like “your partner discount of N% will be applied at the checkout”, and so on.

5) The session clearing code was simply this in the end, just prior to the call to <txp:ign_show_login /> inside the <txp:else /> part of the <txp:ign_if_logged_in /> that surrounds the entire client area:

<txp:php>
	yab_shop_start_session();
	$cart =& $_SESSION['wfcart'];
	if (!is_object($cart)) {
		$cart = new wfCart();
	}
	$cart->empty_cart();
</txp:php>

Thus the cart is emptied on logout. Absolutely awesome. Thanks a million, trenc.

Last edited by Bloke (2009-06-08 16:40:30)


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

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#332 2009-06-15 18:57:49

kevinpotts
Member
From: Ghost Coast
Registered: 2004-12-07
Posts: 370

Re: yab_shop (simple textpattern shop with paypal support)

OK, one more thing. If I assign a custom shipping cost for each item, it stays the same no matter what the quantity is. So if an item costs 5, and shipping is 2, and I want to purchase 20 of them, the final total is 102.

Right now the calculation is (item cost X quantity) + shipping, where it should be (item cost + shipping) * quantity

Is this intentional?


Kevin
(graphicpush)

Offline

#333 2009-06-16 08:47:30

trenc
Plugin Author
From: ⛵️, currently Göteborg, SE
Registered: 2008-02-27
Posts: 574
Website GitHub

Re: yab_shop (simple textpattern shop with paypal support)

Hi Kevin,

yes it’s intentional. The special (custom) shipping costs are assigned to items/products and not to item quantities.


Digital nomad, sailing the world on a sailboat: 32fthome.com

Offline

#334 2009-06-16 13:31:23

kevinpotts
Member
From: Ghost Coast
Registered: 2004-12-07
Posts: 370

Re: yab_shop (simple textpattern shop with paypal support)

trenc wrote:

yes it’s intentional. The special (custom) shipping costs are assigned to items/products and not to item quantities.

I guess I don’t understand the logic behind this. If an item costs $2 to ship, and they order 100, how can shipping remain $2? I love having the custom shipping field, but at this point I have to hope that someone doesn’t order a lot or they are going to get a great deal on shipping. :(

On a related note, is there any way to implement shipping rate calculators?


Kevin
(graphicpush)

Offline

#335 2009-07-07 15:28:57

mfos
Member
Registered: 2008-12-11
Posts: 34

Re: yab_shop (simple textpattern shop with paypal support)

Great Plugin.
Have a problem – The basket and checkout doesn’t seem to be working correctly.
I added several items to the basket and sometimes it doesn’t update properly when navigating to othe pages etc. I’ve even tried to delete an item in the checkout, says i have deleted the item but if i click on proceed to checkout again, the item appears again in the checkout table.

Problem with page caching? If so how do I stop it?

The basket is put into my ‘header’ form. Shouldn’t be causing an issue there surely.

Any ideas?

Cheers
Mike

Offline

#336 2009-07-09 10:55:28

trenc
Plugin Author
From: ⛵️, currently Göteborg, SE
Registered: 2008-02-27
Posts: 574
Website GitHub

Re: yab_shop (simple textpattern shop with paypal support)

Hi Kevin,

I guess I don’t understand the logic behind this. If an item costs $2 to ship, and they order 100, how can shipping remain $2? I love having the custom shipping field, but at this point I have to hope that someone doesn’t order a lot or they are going to get a great deal on shipping. :(

The logic should be that shipping a bicycle is more expensive than shipping a pen. But shipping 1000 pens should be more or less the same costs as shippping one pen. By shipping 1000 bicycles you should be able of making enough money to ship these free, even if you have to order an extra large truck for shipping.

Btw. I’ve never seen a shop where the shipping costs increase by the amount of items. This would be weird (to me).

On a related note, is there any way to implement shipping rate calculators?

What exactly do you have in mind?


Digital nomad, sailing the world on a sailboat: 32fthome.com

Offline

#337 2009-07-09 10:58:39

trenc
Plugin Author
From: ⛵️, currently Göteborg, SE
Registered: 2008-02-27
Posts: 574
Website GitHub

Re: yab_shop (simple textpattern shop with paypal support)

Hi mfos,

mfos wrote:

Great Plugin.
Have a problem – The basket and checkout doesn’t seem to be working correctly.
I added several items to the basket and sometimes it doesn’t update properly when navigating to othe pages etc. I’ve even tried to delete an item in the checkout, says i have deleted the item but if i click on proceed to checkout again, the item appears again in the checkout table.

Problem with page caching? If so how do I stop it?

The basket is put into my ‘header’ form. Shouldn’t be causing an issue there surely.

Any ideas?

Try do disable the »Send-Last-Modified-Header« in Textpattern Admin Preferences! I Think this causes this behaviour.


Digital nomad, sailing the world on a sailboat: 32fthome.com

Offline

#338 2009-07-09 11:44:32

mfos
Member
Registered: 2008-12-11
Posts: 34

Re: yab_shop (simple textpattern shop with paypal support)

That sorted it.
Many many many thanks.
m

Offline

#339 2009-07-09 22:28:38

mfos
Member
Registered: 2008-12-11
Posts: 34

Re: yab_shop (simple textpattern shop with paypal support)

Hi again, Paypal related question this time.

Call me dumb but i’m struggling to get this sorted.

1. Do I need to buy an SSL cert for this setup?
2. How do I get a Private key? Nothing on my hosting CP (Plesk) that enables me to set one up.
3. I take it I don’t need to generate a button from within paypal.

Also, is there a way to get a product code into the checkout? Use of a custom field etc??

Cheers
Mike

Last edited by mfos (2009-07-10 08:07:01)

Offline

#340 2009-07-10 08:12:34

trenc
Plugin Author
From: ⛵️, currently Göteborg, SE
Registered: 2008-02-27
Posts: 574
Website GitHub

Re: yab_shop (simple textpattern shop with paypal support)

Hi mfos,

1. Do I need to buy an SSL cert for this setup?

No. SSL (in the meaning of a secured connection from client to your webserver) doesn’t make really sense on yab_shop this time, because orders will be send with a non-encrypted email.

2. How do I get a Private key? Nothing on my hosting CP (Plesk) that enables me to set one up.

See below.

3. I take it I don’t need to generate a button from within paypal.

Correct, you don’t need a generated paypal button.

Using Payal:

At first you (the shop owner) need a paypal business account. With an normal user account you can’t do this.

Then follow the instructions described here

Relevant Chapters are:

  • Setting Up Certificates Before Using Encrypted Website Payments
  • Blocking Unprotected and Non-encrypted Website Payments

Summarized you have to do this:

First you need an access to a unix or linux machine with an installed openssl. Maybe you have an ssh access to your hosting or web account and this is a unix or linux so you can do this. If you have no access to a linux/unix-machine you can do this on your home-pc. If you own a windows OS download and install this windows port of OpenSSL. With this tool you can create your private key on a windows pc (not tested, I have no machine running windows, but it should work).

1. First create a private key with the following command:

openssl genrsa -out my-private-key.pem 1024

this will produce a 1024bit long RSA key for you, where my-private-key.pem is the name of the file which will be saved in your home directory.

2. With this key/file you can create your public certificate now:

openssl req -new -key my-private-key.pem -x509 -days 365 -out my-public-certificate.pem

During the generating process you will be asked some questions about the owner of the certificate. The file my-public-certificate.pem will also be saved in the same place as your private key.

3. Then you have to upload your public certificate to your paypal business account. After this procedure you will get your paypal certificate id (CERT ID).

4. Now you can grab the paypal public certificate (it’s a file, too) from you paypal account.

5. As the last step place the three files (your own generated my-private-key.pem, my-public-certificate.pem and the paypal certificate paypal_cert.pem) in your hosting account and configure the shop in yab_shop_config as described in the plugin help.

6. Block unprotected and non-encrypted website payments by logging in your paypal business account. Go to Tab »Profile« -> »Selling Preferences« -> »Website Payment Preferences«. There in the »Encrypted Website Payments section« you should block the non-encrypted webseite
payments.

Same information you can find here in the textpattern forum and the other relevant part in the plugin help.

Last edited by trenc (2009-07-10 08:16:24)


Digital nomad, sailing the world on a sailboat: 32fthome.com

Offline

#341 2009-07-10 10:25:17

mfos
Member
Registered: 2008-12-11
Posts: 34

Re: yab_shop (simple textpattern shop with paypal support)

Hi,
Ah, should have read further into the thread, sorry.

I use a mac so is there a way I can generate the key and cert in terminal or elsewhere?

Cheers
Mike

Offline

#342 2009-07-10 10:30:20

trenc
Plugin Author
From: ⛵️, currently Göteborg, SE
Registered: 2008-02-27
Posts: 574
Website GitHub

Re: yab_shop (simple textpattern shop with paypal support)

Hi,
Ah, should have read further into the thread, sorry.

No problem, the thread is meanwhile very long.

I use a mac so is there a way I can generate the key and cert in terminal or elsewhere?

I think so. IIRC OpenSSL is included in a MacOS installation.

So try it!:)


Digital nomad, sailing the world on a sailboat: 32fthome.com

Offline

#343 2009-07-11 11:54:42

mfos
Member
Registered: 2008-12-11
Posts: 34

Re: yab_shop (simple textpattern shop with paypal support)

Hi,

All sorted with the certificates thanks.

1. Is there a way to easily remove the tax line from checkout?

2. Can I create a custom field for a product code which will be sent to paypal?

Cheers
Mike

Offline

#344 2009-07-12 11:45:02

trenc
Plugin Author
From: ⛵️, currently Göteborg, SE
Registered: 2008-02-27
Posts: 574
Website GitHub

Re: yab_shop (simple textpattern shop with paypal support)

Hi mfos,

1. Is there a way to easily remove the tax line from checkout?

You can comment out the lines in the code. But you have to comment out the lines for the order mails too. But after an yab_shop-update it will be removed again. :(

Another way would be to set the row unvisible via css.

2. Can I create a custom field for a product code which will be sent to paypal?

No sorry, product id or code support is not supported this time.


Digital nomad, sailing the world on a sailboat: 32fthome.com

Offline

#345 2009-07-13 09:41:59

mfos
Member
Registered: 2008-12-11
Posts: 34

Re: yab_shop (simple textpattern shop with paypal support)

Hi again, sorry about this.

I’ve commented out the line on the checkout table which is cool.

I can see the line in the config line for the email, but i’ve realised that I’m not actually getting any emails. I only appear to receive paypal sandbox emails. Should I be receiving emails from the site itself only if payment isn’t paypal?

Cheers
Mike

Last edited by mfos (2009-07-13 09:43:54)

Offline

Board footer

Powered by FluxBB