Forums / General Questions / Set a flat shipping cost for a single item

Set a flat shipping cost for a single item

Views: 2,357

Results 21 to 37 of 37
28 Mar 2012, 7:33 AM
#21
gloerick avatar

gloerick

Zen Follower

Join Date:
Feb 2006
Location:
Boise, ID
Posts:
330
Plugin Contributions:
0

Set a flat shipping cost for a single item

it seems the pID is the issue for the shipping not turnning on/off with a click as the pID is "1" and the pID to change the status for the item "in this items case is the pID of 131 so the pID is not updating for the shipping icon.

currently using :

<?php if ($products->fields['product_is_always_free_shipping'] == '1') { echo '<a href="' . zen_href_link(FILENAME_CATEGORIES, 'action=setflag&flag=0&pID=' . $products->fields['product_is_always_free_shipping'] . '&cPath=' . $cPath . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '')) . '">' . zen_image(DIR_WS_IMAGES . 'free_shipping_set.png', IMAGE_ICON_STATUS_ON) . '</a>'; } else { echo '<a href="' . zen_href_link(FILENAME_CATEGORIES, 'action=setflag&flag=1&pID=' . $products->fields['product_is_always_free_shipping'] . '&cPath=' . $cPath . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '')) . '">' . zen_image(DIR_WS_IMAGES . 'icon_red_on.gif', IMAGE_ICON_STATUS_OFF) . '</a>'; } ?>
28 Mar 2012, 1:19 PM
#22
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Set a flat shipping cost for a single item

The pID needs to be the products_id and you are using the setting for the:
product_is_always_free_shipping

which will always be 1 or 0 ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

28 Mar 2012, 2:59 PM
#23
gloerick avatar

gloerick

Zen Follower

Join Date:
Feb 2006
Location:
Boise, ID
Posts:
330
Plugin Contributions:
0

Re: Set a flat shipping cost for a single item

ok, so I have

<?php if ($products->fields['product_is_always_free_shipping'] == '1') { echo '<a href="' . zen_href_link(FILENAME_CATEGORIES, 'action=setflag&flag=0&pID=' . $products->fields['products_id'] . '&cPath=' . $cPath . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '')) . '">' . zen_image(DIR_WS_IMAGES . 'free_shipping_set.png', IMAGE_ICON_STATUS_ON) . '</a>'; } else { echo '<a href="' . zen_href_link(FILENAME_CATEGORIES, 'action=setflag&flag=1&pID=' . $products->fields['products_id'] . '&cPath=' . $cPath . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '')) . '">' . zen_image(DIR_WS_IMAGES . 'icon_red_on.gif', IMAGE_ICON_STATUS_OFF) . '</a>'; } ?>

why is the truck still trigering the item status on/off

and in categories.php I have

break;
 case 'setflag':
  if ( ($_GET['flag'] == '0') || ($_GET['flag'] == '1') ) {
    if (isset($_GET['pID'])) {
      zen_set_product_is_always_free_shipping($_GET['pID'], $_GET['flag']);

    }
  }
28 Mar 2012, 3:02 PM
#24
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Set a flat shipping cost for a single item

Did you change the:
case 'setflag':

or did you just duplicate it? and now have two sections for:
case 'setflag':

If you duplicated it, then it is not "hearing" your duplicate ... it is hearing the original code in the first:
case 'setflag':

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

28 Mar 2012, 3:05 PM
#25
gloerick avatar

gloerick

Zen Follower

Join Date:
Feb 2006
Location:
Boise, ID
Posts:
330
Plugin Contributions:
0

Re: Set a flat shipping cost for a single item

yes I duplicated it and changed the zen_set

  break;
  case 'setflag':
  if ( ($_GET['flag'] == '0') || ($_GET['flag'] == '1') ) {
    if (isset($_GET['pID'])) {
      zen_set_product_status($_GET['pID'], $_GET['flag']);
    
    }
  }
break;
 case 'setflag':
  if ( ($_GET['flag'] == '0') || ($_GET['flag'] == '1') ) {
    if (isset($_GET['pID'])) {
      zen_set_product_is_always_free_shipping($_GET['pID'], $_GET['flag']);

    }
  }

Like I said, I am not a programer, so I do not see what is wrong when I changed teh zen_set from staus to shipping

28 Mar 2012, 3:16 PM
#26
gloerick avatar

gloerick

Zen Follower

Join Date:
Feb 2006
Location:
Boise, ID
Posts:
330
Plugin Contributions:
0

Re: Set a flat shipping cost for a single item

tried setting

break;
case 'setflagshipping':

AND

zen_href_link(FILENAME_CATEGORIES, 'action=setflagshipping&flag=0&pID='

to give the setflag a uniqe name.

28 Mar 2012, 3:51 PM
#27
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Set a flat shipping cost for a single item

Did you make a function for:
zen_set_product_is_always_free_shipping

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

28 Mar 2012, 5:12 PM
#28
gloerick avatar

gloerick

Zen Follower

Join Date:
Feb 2006
Location:
Boise, ID
Posts:
330
Plugin Contributions:
0

Re: Set a flat shipping cost for a single item

your tourchering me huh, you know I most likley did not,
and no, no idea I had to or how to.

can you please guide me to get it working ?

28 Mar 2012, 5:14 PM
#29
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Set a flat shipping cost for a single item

Create a new file in:
/admin/includes/functions/extra_functions

call it something like:
always_free_shipping_functions.php

and add the code:

<?php
////
// Sets the status of a product
  function zen_set_product_is_always_free_shipping($products_id, $always_free_shipping_status) {
    global $db;
    if ($always_free_shipping_status == '1') {
      return $db->Execute("update " . TABLE_PRODUCTS . "
                           set product_is_always_free_shipping = 1, products_last_modified = now()
                           where products_id = '" . (int)$products_id . "'");

    } elseif ($always_free_shipping_status == '0') {
      return $db->Execute("update " . TABLE_PRODUCTS . "
                           set product_is_always_free_shipping = 0, products_last_modified = now()
                           where products_id = '" . (int)$products_id . "'");

    } else {
      return -1;
    }
  }

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

28 Mar 2012, 5:20 PM
#30
gloerick avatar

gloerick

Zen Follower

Join Date:
Feb 2006
Location:
Boise, ID
Posts:
330
Plugin Contributions:
0

Re: Set a flat shipping cost for a single item

copy this from the general.php ?

// Sets the status of a product
function zen_set_product_status($products_id, $status) {
global $db;
if ($status == '1') {
return $db->Execute("update " . TABLE_PRODUCTS . "
set products_status = 1, products_last_modified = now()
where products_id = '" . (int)$products_id . "'");
} elseif ($status == '0') {
return $db->Execute("update " . TABLE_PRODUCTS . "
set products_status = 0, products_last_modified = now()
where products_id = '" . (int)$products_id . "'");
} else {
return -1;
}
}

all I did was search for zen_set_product_status

28 Mar 2012, 5:33 PM
#31
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Set a flat shipping cost for a single item

Use the code that I posted and put it in a file like I posted ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

28 Mar 2012, 6:38 PM
#32
gloerick avatar

gloerick

Zen Follower

Join Date:
Feb 2006
Location:
Boise, ID
Posts:
330
Plugin Contributions:
0

Re: Set a flat shipping cost for a single item

That did it, it all works and the format looks right.

Thank you again, hope all this can help others add this or other Items of a product to turn on/off.

28 Mar 2012, 6:46 PM
#33
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Set a flat shipping cost for a single item

Thanks for the update that this is working for you ...

Remember the Zen Cart Team when you are rich and famous! :cool:

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

28 Mar 2012, 7:10 PM
#34
gloerick avatar

gloerick

Zen Follower

Join Date:
Feb 2006
Location:
Boise, ID
Posts:
330
Plugin Contributions:
0

Re: Set a flat shipping cost for a single item

done, made a small $50 donation, the help is invaluable !!!
as we grow we will do more..

28 Mar 2012, 10:44 PM
#35
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Set a flat shipping cost for a single item

Thanks very much for your support ... always a great help to our providing you with the Free e-commerce code and support forums ... :cool:

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

5 Apr 2012, 12:32 PM
#36
thegoodlifestore avatar

thegoodlifestore

New Zenner

Join Date:
Oct 2007
Location:
North Carolina
Posts:
102
Plugin Contributions:
0

Re: Set a flat shipping cost for a single item

Ajeh:

Set the weight of the Product to 0, then, in the function quote of your shipping modules you could use:

global $cart;
$chk_products = 0;
$extra_products_charge = 0.00;

// check for products_id 12 and add $5.00 to shipping
$chk_products += $_SESSION['cart']->in_cart_check('products_id','12');
if ($chk_products > 0) {
$extra_products_charge = 5.00;
}

> 
> Then, add the new variable:
> $extra_products_charge
> 
> to the cost on your shipping module(s) ...

This sounds like the solution I need ... but I am a bit confused as where exactly to place this code. We are using 1.3.9h and the UPS shipping module.

Thanks in advance for any help!
5 Apr 2012, 1:12 PM
#37
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Set a flat shipping cost for a single item

Look in the ups.php module for this section of code:

        if (!in_array($type, $allowed_methods)) continue;
        // EOF: UPS USPS
        $cost = preg_replace('/[^0-9.]/', '',  $cost);
        $methods[] = array('id' => $type,
                           'title' => $this->types[$type],
                           'cost' => ($cost * $shipping_num_boxes) + (MODULE_SHIPPING_UPS_HANDLING_METHOD == 'Box' ? MODULE_SHIPPING_UPS_HANDLING * $shipping_num_boxes : MODULE_SHIPPING_UPS_HANDLING) );
      }

add the new code below the line:

        $cost = preg_replace('/[^0-9.]/', '',  $cost);

then add the $extra_products_charge to the cost:

        $methods[] = array('id' => $type,
                           'title' => $this->types[$type],
                           'cost' => $extra_products_charge + ($cost * $shipping_num_boxes) + (MODULE_SHIPPING_UPS_HANDLING_METHOD == 'Box' ? MODULE_SHIPPING_UPS_HANDLING * $shipping_num_boxes : MODULE_SHIPPING_UPS_HANDLING) );

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!