Shopping cart - Page 20 Shopping cart - Page 20
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

Shopping cart

Started by Stramm, June 04, 2006, 09:02:32 AM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

Stramm

remove unnecessary wording to make it smaller... eg there's the white heading 'Add image to shopping basket: ' on white background before the dropdown... remove it (lang/english.php) or make it smaller an you should be good

krp

Thank you for support Stramm. Everything working great. Thank you again :) :) :) ;D

JohannM

Hi Stramm

It's nearly Christmas ... and due to your excellent mod I am managing to make some money for a change. I owe you a Christmas present all the way from South Africa, so please pm me with some contact details.

Anyway (this is not bribing) I do have a question: I am busy with a website for temp tattoos.  There are 4 Types, about 6 sizes, and 200 + designs per tattoo ... I need to sell them (per size) for a certain amount at certain prices.  How do I do this when adding the information to the shop config ?

Stramm

Easiest way to do that would be to add for each type all sizes.
-type 1 4x6
-type 1 5x7
-type 1 6x8
-type 1 7x9
-type 2 4x6
-type 2 5x7
-type 2 6x8
-type 2 7x9
.... that for all four types
if you look for let's say two dropdowns, one with type, the other containing the size... then this is not possible without changing a good bunch of code in nearly all files. Also db modifications would be necessary. A task that can't be done in a few minutes.

JohannM

Hi Stramm

Thanx, yea, I figured it would be the only way, it will take me a while, but I guess ones it's done, it's done.

The only thing I don't like is that as soon as you add an item (or all items), it automatically adds it to all albums ... in what code can I change to NOT add it, but rather let me enable the albums for the prices as I wish ...

Thanx yet again for all your help.

Stramm

to exclude certain albums from the shop functionality is a shop admin setting as well as letting certain albums override the global prices.

If you want to not exclude but rather enable the shop for certain albums you'll have to change code as you said. That code you can find in codebase.php function add_item (I think it was).

JohannM

Stramm

If I want to enable discount for a user group called Agents ... how do I fix the code to ONLY give them discount based on number of pics they order ? This will be in functions.php.

Something like:

function calculate_discount($temp_price, $cd_counter){

   $discount = '';
   //variables that can be used
   //$cd_counter['photo']  number of pics for print
   //$cd_counter['cd']      number of pics on CD
   //$temp_price[1]      price for the CD
   $temp_price[0];      //price for the pics

   //just to demonstrate how to calculate a discount
   //10% on print images if user orders more than 10 pics
   
   if ((!USERGROUP) >= AGENTS)) {
   if($cd_counter['photo'] >= 0);
   
      $discount = 0.1 * $temp_price[0];
   }
   

   /*
   //or another example... 10% if the order volume is > 100USD
   if($temp_price[0] >= 100) {
      $discount = 0.1 * $temp_price[0];
   }
   */
   return $discount;
}

Stramm

Looks somehow made up with some syntax errors. At least a constant USERGROUP isn't defined
You could try that instead

if (USER_GROUP == 'AGENTS') {
$discount = 0.1 * $temp_price[0];
}

JohannM

Hi Stramm

Thanx for the help ... I created two groups with different discounts .... problem is that altough the calculation is correct, the total amount seems to be wrongly calculated ...

Products: 1 Design(s) ::   R  35,000.00
Agent Discount :: % :: R 5,250.00
Total: R  34,995.00

Also the percentage discount before the % sign do not show ....

Can you help please ?

Thanx in advance


Stramm

this is how it should look
Quote
For print: 7 pics :: 14.00USD
Shipping :: 4.00USD
Discount :: % 1.40USD 
Total: 16.60USD

And as you can see it works pretty good.  I do not know what you've modified so I can not give you much advice.

JohannM

I don't charge shipping ... can that be the problem ?

Stramm


JohannM

Stramm

The % gives the discount amount and not the percentage and the discount amount (e.g.  15% :: R 25.00 )

Is there a way to indicate the discount percentage ?

Stramm

I digged around and have seen that there indeed is a problem. Will look into this tomorrow.

The percentage as you want to display it isn't known by the system. You can define the discount in the function you just modified and here you can do whatever math you like and not just using percentages (% is in my country the sign for difference, if you do not like it you can renove it - has been asked and answered before)

Stramm

#394
Here's the fix for your problem. It occurs when the numbers are >= 1000. The problem was the formatted output of the numbers (eg. 12,000.00 instead of 12000.00).

In plugins/pgoto_shop/include/functions.inc.php find
$discount = number_format(calculate_discount($temp_price, $cd_counter),2);
$shipping = number_format(calculate_shipping(),2);
$tot_price = number_format(($temp_price[1]+$temp_price[0]+$shipping-$discount),2);
$cd_price = number_format($temp_price[1],2);
$photo_price = number_format($temp_price[0],2);

and replace with
$discount_calc = calculate_discount($temp_price, $cd_counter);
$shipping_calc = calculate_shipping();
$discount = number_format(($discount_calc),2);
$shipping = number_format(($shipping_calc),2);
$tot_price = number_format(($temp_price[1]+$temp_price[0]+$shipping_calc-$discount_calc),2);
$cd_price = number_format($temp_price[1],2);
$photo_price = number_format($temp_price[0],2);


edit: added number format for discount and shipping as noted by JohannM 2 posts below

JohannM

Hi Stramm

Seems to me the calculations is correct now, but the discount amount is not with decimal places:

Products: 2 Design(s) ::   R  57,500.00
Discount :: % :: R  14,375
Total: R  43,125.00

Is there a way to have fixed digits (e.g. 9 number format) ?

JohannM

should be:

    $discount_calc = calculate_discount($temp_price, $cd_counter);
   $shipping_calc = calculate_shipping();
   $discount = number_format(($discount_calc),2);
   $shipping = number_format(($shipping_calc),2);
   $tot_price = number_format(($temp_price[1]+$temp_price[0]+$shipping_calc-$discount_calc),2);
   $cd_price = number_format($temp_price[1],2);
   $photo_price = number_format($temp_price[0],2);

That is fixed now ...

Just wonder about fixed length of digits ...


JohannM

Stramm

Just a question ... if you add an item to the shopping basket, for a brief moment the page refresh with only the footer (Powered by Coppermine) etc.

Is there a way to add a line there for e.g. "Adding product to basket" ? And where in what file (line) can I add this ?

Check out my new site:  http://www.temp-tattoos.co.za/agents/

I'm still doing some changes ...

Stramm

yah, I always wanted to add this... started to code it but never finished. Somehow I had implemented it but, hmmm... I didn't like it. The remainings you'll come across when I show you what to do.

plugins/photo_shop/codebase.php find
photoshop_refresh($referer);
replace with
photoshop_refresh($referer, $lang_photoshop['added']);


plugins/photo_shop/include/functions.inc.php
replace the already existing function photoshop_refresh with this new one
function photoshop_refresh($redirect, $txt='') {
global $lang_info;

            pageheader($lang_info, "<META http-equiv=\"refresh\" content=\"0;url={$redirect}\">");
            if($txt !='') {
msg_box ($txt, $txt);
}
            pagefooter();
            ob_end_flush();
exit;
}