Support » Plugin: WP eCommerce » Shipping Insurance for all items in cart hack

  • ***If you’re advanced or just wanna skip straight to the “how to and where to add code” feel free to skip to it.There are two ways to pull this off***

    I’d like to state I am not coder and I am very new to php but I thought I would post this information because it has been an ongoing problem with no real solution for a while now.

    My Problem:
    Basically I added my own flat rate shipping price to each of my products based on the item I’m shipping (weight size etc). I’m not using a shipping calculator and I only ship through usps and process payments through paypal. So my issue was that there was no option to add shipping insurance to the entire order (which is $1.95 through usps) at checkout. I thought maybe a variation would work but then it would be annoying if I had too many products and had to go and individually add that in to each one of them and that would also confuse people if they had multiple products in their cart. So here we go to get to my solution.

    My solution:
    I created a “Shipping Insurance” product that could be added to cart and then added to the checkout just like any other product. That created the issue of the “Shipping Insurance” product showing on the product page which I did NOT want. So I found a code to block certain product categories from showing on the product page. I put the “Shipping Insurance” product in a “shipping” category and blocked it from being displayed on the product page. Now I had the issue of somehow creating a button to add the “Shipping Insurance” to the checkout page and having the cart update to the correct price. I ended up needing to hack my wpsc_shopping_cart_page.php (in my theme folder) and I needed to hack one of my other core files to pull this off. (/plugins/wp-e-commerce/wpsc-includes/shortcode.functions.php)

    I created two ways to make this happen.

    1. A button on the checkout page that you click and it opens the “thickbox” window and displays an html page with a button to add the shipping insurance and sends you back to a refreshed checkout page with the new total. The shipping insurance is a product so it is added to the list with the rest of the items in your cart. With this popup you are also able to leave a message with the button explaining anything about the insurance you would like to. (this can be used for other things as well)

    2. Buttons on the checkout page that when clicked directly add shipping insurance and refresh the page displaying the new total.

    So here are the instructions and codes to pull this off.

    1. Create a product called “Shipping Insurance”

    -Disable shipping for product
    -Upload a product picture
    -Create a category called “shipping” and put it in that category

    2. Hide the category from showing on your product page with this code. You will place this in your theme files (wpsc-products_page.php wpsc-grid_view.php)

    I am using gridview so I edited wpsc-grid_view.php and found the code to replace at around line 60 you should see this…

    <script src=’’>

    Replace it with:

    <br />
    <div class="product_grid_display group"><br />
    <?php while (wpsc_have_products()) : wpsc_the_product(); ?><br />
    <?php<br />
    $prod_id = wpsc_the_product_id();<br />
    $category = get_the_product_category( $prod_id );<br />
    //echo('<br />
    ');<br />
    if($category[0]->term_id == 95){<br />
    //skip<br />
    } else {?></p>
    <p><div class="product_grid_item product_view_ <?php echo wpsc_the_product_id(); ?>"></p>
    <p><?php if(wpsc_the_product_thumbnail()) :?><br />
    <div class="item_image"><br />

    where it says term_id == 95)
    you need to change that to the category ID for your shipping product you created.

    You need to click save and view the page. You will get a php parse error and it will tell you the

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Shipping Insurance for all items in cart hack’ is closed to new replies.