Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

Sebastian Graus
Sebastian Graus
633 Points

WooCommerce editing PHP to change checkout

Hi,

I'm just learning PHP and am also building a webshop for a client of mine. It is webshop that is supposed to sell liqour. Allthough, the final order and payment won't be happening on the clients website, but on a third party website. So what I am trying to achieve is that the visitor can add products to a cart, and than once done on site1 it will be sent to thirtpartywebsite.com where they will fulfill their order and payment. The link for this is as following:

www.systembolaget.se/Dryckeslista/?a=[ArtikelNr1],[Quantity]&a =[ArtikelNr2],[Quantity]&a =[ArtikelNr3],[Quantity1]

So, I guess I have to wright some PHP code. Something like this:

www.systembolaget.se/Dryckeslista/?a=<?php echo $artikelnr; ?>,<?php echo $quantity; ?>&a =<?php echo $artikelnr; ?>,<?php echo $quantity; ?>&a =<?php echo $artikelnr; ?>,<?php echo $quantity; ?>

And it gets the artikelnr and the quantity from the cart. So somewhere this code has to go, right?

JUST A EXAMPLE (unique for every product)

<?php

$artikelnr = "12345";
$quantity = "1";

?>

This would create this link in HTML

www.systembolaget.se/Dryckeslista/?a=12345,1

My questions are:

Where do I put the above code? Is it in the woo commerce file class-wc-cart.php file?

What is the code to do this automatic for every product in the cart?

How do I get the $artikelnr and $quantity for every product?

I have a feeling this is not way to hard, howevery if you feel that this is pretty advanced coding and that my question is way to much for ask for, please tell me and I will instead hire some outside help for this instead.

With best wishes,

Sebastian

shahardekel
shahardekel
20,306 Points

If you are using woo commerce, then you are using wordpress, which is by itself a great framework, but requires some understanding of both php, and how wordpress itself works and how woo commerce is integrated. I'm no expert in woo commerce, but there are some really good courses here about it to get you started.