WordPress.org

Forums

WP eCommerce
Shipping Insurance for all items in cart hack (3 posts)

  1. missodessa
    Member
    Posted 1 year ago #

    ***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='http://pastie.org/8497552.js'>
    </script>

    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 />
    <pre>'.print_r($category,1).'</pre>
    ');<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

    http://wordpress.org/plugins/wp-e-commerce/

  2. missodessa
    Member
    Posted 1 year ago #

    I have edited this post on my blog because the editor seems to be putting break tag in my php code you can find the post with the full code here

    http://www.odessabuggs.com/web-and-graphic-designs/wp-ecommerce-shipping-insurance-hack/

  3. Dan Milward
    Member
    Plugin Contributor

    Posted 1 year ago #

    @missodessa - you my dear are a legend! merry xmas!

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WP eCommerce
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags

No tags yet.