Post by Uberos » Mon Oct 21, 2013 7:16 pm

Hi all,

I have only one country defined in module "Weight Based Shipping". I'd like show shipping cost in product page coding quickly in php. Any ideas?
Last edited by Johnathan on Thu Oct 24, 2013 10:42 pm, edited 1 time in total.
Reason: Remove [HOW TO] from topic title -- that's for topics that *describe* how to do something

Newbie

Posts

Joined
Fri Nov 09, 2012 5:21 pm

Post by mlimacarlos » Thu Oct 24, 2013 12:26 pm

How is the shipping method?
Maybe you can calculate de shipping when product/product is called.

[]s
Marcos

Newbie

Posts

Joined
Sat Apr 20, 2013 7:25 am

Post by Uberos » Thu Oct 24, 2013 8:33 pm

In my store shipping method is always "Weight Based Shipping".

I have the product weight when product/product is called but i need read cost prices defined in "Weight Based Shipping" module just for my country.

I don't know how to code...

Newbie

Posts

Joined
Fri Nov 09, 2012 5:21 pm

Post by Johnathan » Thu Oct 24, 2013 10:44 pm

You could use my Shipping Estimate Module to allow the customer to get a quote based on their location, and assign the module to only appear on the product page layout.

Image
Image Image Image Image


User avatar
Global Moderator

Posts

Joined
Fri Dec 18, 2009 3:08 am


Post by Uberos » Fri Oct 25, 2013 12:30 am

Thankyou very much, but i don't need your module, i need only information...

Where can i read weight/prices defined in "Weight Based Shipping" module?

Newbie

Posts

Joined
Fri Nov 09, 2012 5:21 pm

Post by Johnathan » Fri Oct 25, 2013 11:22 pm

The data for extensions is contained in the "setting" table, so you could pull the rates from there using a database query. If you don't know how to code, though, you might want to read up on PHP and MySQL.

Image
Image Image Image Image


User avatar
Global Moderator

Posts

Joined
Fri Dec 18, 2009 3:08 am


Post by Uberos » Tue Oct 29, 2013 2:42 am

Thankyou Johnathan, i did it!

in controller/product:

$this->data['weight'] = $product_info['weight'];

in template product page:

Code: Select all

<?php
            $delivery_query=mysql_query("SELECT value FROM `setting` T1 where T1.group = 'weight' and T1.key = 'weight_4_rate'");
            while($row=mysql_fetch_array($delivery_query)){
               $delivery=explode(',',$row['value']);
               foreach($delivery as $rate){
                    $pos = strpos($rate, ':');
                    $r_weight=substr($rate, 0, $pos);
                    $r_cost=substr($rate, $pos+1, strlen($rate)-1);
                    if ($r_weight > $weight) {
                         echo "<span class='shipping'><b>Shipping: ".$r_cost." €</b>";
                         break;
                    }
               }
            }
        ?>
Last edited by Johnathan on Tue Oct 29, 2013 10:45 pm, edited 1 time in total.
Reason: Added [code] tags for readability

Newbie

Posts

Joined
Fri Nov 09, 2012 5:21 pm
Who is online

Users browsing this forum: No registered users and 7 guests