Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Help with php code ~


Darklings

Recommended Posts

No idea how or where i should place this - pardon me if i did it wrong.

 

But i'm customizing my shop - and am near the finish - but i'm stuck now at one little thingy for almost 3 days - i'm disperate. I wondered if someone familier with the php-code (especialy with pricing (shopping_cart etc...)) could take a look for me and help me out - i'm sure it aint much - but i'm realy stuck here. I'm not looking for a freelancer, and i might wanna release this as a contrib if enouf people would be interested.

 

I can get on msn - would make it easier to talk - or pm me here.

 

Kind Regards,

Tom

Even in this dark place, yes, I am afraid of my own shadow.

 

 

 

Contributions | KnowledgeBase | osCommerce 2.2 pdf

Link to comment
Share on other sites

No idea how or where i should place this - pardon me if i did it wrong.

 

But i'm customizing my shop - and am near the finish - but i'm stuck now at one little thingy for almost 3 days - i'm disperate. I wondered if someone familier with the php-code (especialy with pricing (shopping_cart etc...)) could take a look for me and help me out - i'm sure it aint much - but i'm realy stuck here. I'm not looking for a freelancer, and i might wanna release this as a contrib if enouf people would be interested.

 

I can get on msn - would make it easier to talk - or pm me here.

 

Kind Regards,

Tom

 

why not spend all these characters to explain what you need.

Treasurer MFC

Link to comment
Share on other sites

i would love to - but its a bit complicated - ... - since i explained it on these forums a couple of times already :s

 

~ But i'll give it a try ~

 

I'm now working on a recalculation of my price.

What i got so far:

 

qty_blocks :20 //is an amount you can give in at admin

qty Fee:0.5000 //price that you give in at admin

Prijs per stuk:9.0000 //price that you give in at admin

qty :21 //how many times you ordered one product

rest:1 //rest = the product you ordered out of the block

qty min rest:20 //what it said = qty - rest

prijs + Fee: 9.5 //price + Fee (also set in admin)

prijs1 :9.5 // calculates (Price+Fee) * rest

prijs2 :180 // calculates price * qty-rest

totaal :189.5 //prijs1 + prijs2

 

this is something i put in my shoppingcart using the print_r (i just added some info behind them now)

 

What my code does:

 

It first checks if your allowed to order under/above the qty_blocks that are set in admin (I have SPPC installed - IF a group is set at 0 qty_fee, they have to order in blocks of given qty_blocks ELSE they are able to order whatever number - but get the qty_fee for each qty that doesnt fit in the qty_block)

 

So now i'm working on the calculation of the fee ~ witch works just fine (seeing my explanation above) but he wont take it into my shoppingcart and wont take it to the Checkout_Confirmation page - and i just dont understand why.

 

I'm actualy verry new to php and this must be something verry small - but i find it hard not only to explain, but this is about 4 different pages (classes/shopping_cart.php, classes/PriceFormatter.php, shopping_cart.php, checkout_confrimation.php)

 

Anything more you need to know??

 

:s this is not easy to explain... just ask what there is you dont understand..

 

So the main problem is - it does my calculation right - but it wont take my total_price's in the shoppingcart and checkout-confirmation......

 

 

Thnx,

kind regards,

Tom

Even in this dark place, yes, I am afraid of my own shadow.

 

 

 

Contributions | KnowledgeBase | osCommerce 2.2 pdf

Link to comment
Share on other sites

i would love to - but its a bit complicated - ... - since i explained it on these forums a couple of times already :s

 

~ But i'll give it a try ~

 

I'm now working on a recalculation of my price.

What i got so far:

 

qty_blocks :20  //is an amount you can give in at admin

qty Fee:0.5000 //price that you give in at admin

Prijs per stuk:9.0000 //price that you give in at admin

qty :21 //how many times you ordered one product

rest:1 //rest = the product you ordered out of the block

qty min rest:20 //what it said = qty - rest

prijs + Fee: 9.5 //price + Fee (also set in admin)

prijs1 :9.5  // calculates (Price+Fee) * rest

prijs2 :180  // calculates price * qty-rest

totaal :189.5 //prijs1 + prijs2

 

this is something i put in my shoppingcart using the print_r (i just added some info behind them now)

 

What my code does:

 

It first checks if your allowed to order under/above the qty_blocks that are set in admin (I have SPPC installed - IF a group is set at 0 qty_fee, they have to order in blocks of given qty_blocks ELSE they are able to order whatever number - but get the qty_fee for each qty that doesnt fit in the qty_block)

 

So now i'm working on the calculation of the fee ~ witch works just fine (seeing my explanation above) but he wont take it into my shoppingcart and wont take it to the Checkout_Confirmation page - and i just dont understand why.

 

I'm actualy verry new to php and this must be something verry small - but i find it hard not only to explain, but this is about 4 different pages (classes/shopping_cart.php, classes/PriceFormatter.php, shopping_cart.php, checkout_confrimation.php)

 

Anything more you need to know??

 

:s this is not easy to explain... just ask what there is you dont understand..

 

So the main problem is - it does my calculation right - but it wont take my total_price's in the shoppingcart and checkout-confirmation......

Thnx,

kind regards,

Tom

 

ouch, almost sorry I asked.

 

basically, you have the total price per item calculated according to your own schema.

 

now, normally that price is calculated by the cart object and displayed there. That you need to alter. So revise the statements like $cart->show_total;

 

then you need to figure out when and how the order object is populated with the "final price" value for a product. I have not investigated this but I believe there is where you need to insert your calculated price as that order object is carried along the checkout process pages.

 

I will do some investigation as I want to know how this was set up anyway, just need a little time.

Treasurer MFC

Link to comment
Share on other sites

ouch, almost sorry I asked.

 

basically, you have the total price per item calculated according to your own schema.

 

now, normally that price is calculated by the cart object and displayed there. That you need to alter. So revise the statements like $cart->show_total;

 

then you need to figure out when and how the order object is populated with the "final price" value for a product. I have not investigated this but I believe there is where you need to insert your calculated price as that order object is carried along the checkout process pages.

 

I will do some investigation as I want to know how this was set up anyway, just need a little time.

 

Thnx for having a look amanda - but this is even more complicated then you think - i even got another calculation at the checkout_confirmation where products are ordered by category and you get a %discount when you order above a given qty (should be implemented in admin, but is right now hardcoded in my checkout_confirmation.php page)

 

i'll add some screenshots here : maybe you'll understand better what the problem is then......

 

ss_shoppingcart.png

 

and a ss of my complicated checkout_confirmation :s

 

ss_confirmation.png

 

 

 

 

THnx for having a look

kind regards,

tom

Even in this dark place, yes, I am afraid of my own shadow.

 

 

 

Contributions | KnowledgeBase | osCommerce 2.2 pdf

Link to comment
Share on other sites

Oops, didnt know they would come up that big :s sorry....

 

 

anyway - in the first ss - it looks like it is working -but its not - as soon as i add a new product to the cart - it takes a total price the same as the last product that was added - (ex. if a new product was 10$ my first products price would be 10$ too )

Even in this dark place, yes, I am afraid of my own shadow.

 

 

 

Contributions | KnowledgeBase | osCommerce 2.2 pdf

Link to comment
Share on other sites

Thnx for having a look amanda - but this is even more complicated then you think - i even got another calculation at the checkout_confirmation where products are ordered by category and you get a %discount when you order above a given qty (should be implemented in admin, but is right now hardcoded in my checkout_confirmation.php page)

 

i'll add some screenshots here : maybe you'll understand better what the problem is then......

 

ss_shoppingcart.png

 

and a ss of my complicated checkout_confirmation :s

 

ss_confirmation.png

THnx for having a look

kind regards,

tom

 

sure, I too have a special category discount module that gives additional disounts if more than a certain amount of products are ordered from the same "specified" category. But that is "on top of".

 

First things first, lets first see how to get a customized price of a product in the cart information and all the way to checkout in the order information. When we get that far, we worry about additional calculations.

Treasurer MFC

Link to comment
Share on other sites

First things first, lets first see how to get a customized price of a product in the cart information and all the way to checkout in the order information. When we get that far, we worry about additional calculations.

 

I assume that you have a function that will calculate the price for you - in /includes/classes/shopping_cart.php you must apply your function to the following:

 

          $products_price = $product['products_price'];

 

eg.

 

          $products_price = tep_my_function($product['products_id']);

 

Matti

Link to comment
Share on other sites

I assume that you have a function that will calculate the price for you - in /includes/classes/shopping_cart.php you must apply your function to the following:

 

 ? ? ? ? ?$products_price = $product['products_price'];

 

eg.

 

 ? ? ? ? ?$products_price = tep_my_function($product['products_id']);

 

Matti

 

 

Hi Johnson,

 

In my classes/shopping_cart.php i added,in the //products price section (around line 255 on mine)

 

  $pf->loadProduct($products_id, $languages_id);
 $qb = $pf->getQtyBlocks();
 $qtyT = $pf->getQtyToeslag();

$rest = $qty % $qb; // berekenen van de rest (hoeveelheid % hoeveelheidsblok)
$qty_min_rest = $qty - $rest; // hoeveelheid - rest
$EH_prijs_plus_toeslag = $this->total += tep_add_tax($products_price, $products_tax) + $qtyT; // eenheidsprijs plus toeslag

$prijs1 = $EH_prijs_plus_toeslag * $rest; //rekent de totaalprijs uit met toeslag 
$prijs2 = $this->total = tep_add_tax($products_price, $products_tax) * $qty_min_rest; // rekent de totaalprijs uit zonder toeslag
if ($qtyT == 0){ //als de qty_toeslag gelijk is aan 0 dan:
         $this->total = tep_add_tax($products_price, $products_tax) * $qty;
   }
else
{
$this->total = $prijs1 + $prijs2;
}

 

when i run a print_r for all these (ex $qty, $prijs1 etc...) i get everything calculated the right way (like you see on my ss above)

 

Is that not the way to do it then?

oh, one more thing, i use the PriceFormatter, a file that calc prices, made by janz for sppc...

 

in my priceformatter i got this:

 

function adjustQty($qty) {
// Force QTY_BLOCKS granularity

$qtyT = $this->getQtyToeslag(); //roep functie op
if ($qtyT == 0){ // <= kijken of er een toeslagprijs is
// zo nee, aanpassen aan EHV ->
$qb = $this->getQtyBlocks(); // roep functie qtyblocks op
if ($qty < 1) //als hoeveelheid kleiner is dan 1 dan
 $qty = 1; // hoeveelheid = 1

if ($qb >= 1) // als hoeveelhiedsblok groter is dan 1 dan
{
 if ($qty < $qb) // als hoeveelheid kleiner is dan hoeveelheidsblok dan
	 $qty = $qb; // hoeveelheid gelijk zetten aan hoeveelheidsblok

 if (($qty % $qb) != 0) // als de rest van (hoeveelheid / hoeveelheidsblok) niet gelijk is aan 0 dan
	 $qty += ($qb - ($qty % $qb)); // hoeveelheid + (hoeveelheidsblok - rest van (hoeveelheid / hoeveelheidsblok)
}
return $qty; // toon hoeveelheid
  	 } // end of if ($qtyToeslag == 0)
// ja, dan hoeft qty niet aangepast te worden:
return $qty; //toon hoeveelheid
}

 

To check if your alowed to order out of the qtyblocks.

 

I know its prob better to put what i've done in the classes/shopping_cart.php also in this priceformatter, but i tried and it didnt worked, so i placed it here for now.

 

 

 

 

Kind Regards,

tom

Even in this dark place, yes, I am afraid of my own shadow.

 

 

 

Contributions | KnowledgeBase | osCommerce 2.2 pdf

Link to comment
Share on other sites

You are applying this to the cart total only, not the products_price:

 

$EH_prijs_plus_toeslag = $this->total += tep_add_tax($products_price, $products_tax) + $qtyT;

 

Matti

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...