Kryptronic Software Support Forum

You are viewing this forum as a guest. Login to an existing account, or create a new account, to reply to topics and to create new topics.

#1 04-21-2017 09:12:37

robprotronica
Member
Registered: 12-16-2008
Posts: 106

Add Shipping Cost Indications to Product Offer Display

We would like to add some shipping cost indications to the product detail page.

Whilst we use the Custom Shipping Methods to actually calculate the shipping cost we have previously used the Item Based shipping info to populate an indication of shipping cost - It is a very easy place to enter the data.

Looking in prodshow.php the array $proddisp has all the data a couple of arrays down.

The following gives the value of the first Item Based shipping name:-

Code:

print $proddisp['xpricemap']['DEFAULT-DEMO-100-DEFAULT-DEMO-100']['xinvid']['shiponename'];

The following also works in returning the key of the second array:-

Code:

reset($proddisp);
$first_key = key($proddisp['xpricemap']);
print $proddisp['xpricemap'][$first_key]['xinvid']['shiponename'];

So I have something that works and in similar fashion will allow me to get at all the values I need e.g. shiponeprice, shiptwoname etc.

What I really need to know is am I building this on sand?

Is there a better way of getting the necessary key in the xpricemap array or will extracting this info from the array itself always work?

Would much appreciate some comment before I go too far down this line.

Thanks

Offline

 

#2 04-24-2017 07:15:31

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19798
Website

Re: Add Shipping Cost Indications to Product Offer Display

A 'customdata' field was added to both the product offers (ecom_prod) and inventory (ecom_inventory) tables in K9 for storage of such data.  I recommend using that, but you're not hurting yourself using 'shiponename'.  Consider, though, that the 'customdata' value gets stored in the cart and would be accessible in your custom shipping script for each item, if you wanted to get to it.

Accessing the 'pricemap' key of the $proddisp array is definitely the way to go.  Just be aware there can be multiple entries in the 'pricemap' array.  Good work here.


Nick Hendler

Offline

 

#3 04-24-2017 11:35:24

robprotronica
Member
Registered: 12-16-2008
Posts: 106

Re: Add Shipping Cost Indications to Product Offer Display

Thanks Nick,

Have been looking into the "customdata" fields - the accessibility of the data is a plus.

At the moment we have not been putting together multi item offers - so fairly straight forward to pick up the data from the pricemap array - and it is very easy to input the data under "Delivery - item based" for the inventory item.

However, whilst a little more care is needed to enter a comma separated list in customdata in the product offer it does tie the shipping info to the specific product offer so is probably the way to go.

Now, how to turn a comma separated string into a key=>value array or maybe "explode" is all I need.

Offline

 

#4 04-25-2017 07:01:56

robprotronica
Member
Registered: 12-16-2008
Posts: 106

Re: Add Shipping Cost Indications to Product Offer Display

Decided to go with the Custom Data field in the Product offer as this really seems to be the best place to put the data.

If we input a comma separated list of shipping methods and prices e.g. :-

   UK Free - Next Business Day Courier,0,Europe - Courier,14.95

The following code picks it up and displays

Code:

     if (!(empty($proddisp['customdata']))) {
     
     print '<p>Shipping Information</p>' .$eol;
     
     $customdata=explode(",",$proddisp[customdata]);
          
     for ($i = 0; $i < count($customdata); $i += 2) {
     
       if ($customdata[($i+1)] =='0') {
       
          print '<p>' . $this->xhtml_encode($customdata[$i]) . '</p>' .$eol;
          
          } else {
          
          print '<p>' . $this->xhtml_encode($customdata[$i]) . ' &pound;' . $this->xhtml_encode($customdata[($i+1)]) . ' inc Vat</p>' .$eol;
          
          } // End of if statement
       }   
     } // End of if statement

The above should work for as many pairs of shipping method and price as we care to put in.

For other uses it is possible to input the custom data comma separated list as triplets or quads etc, just have to change the increment value in the for loop.

As a tidy up we probably want to ad some classes to the <p> tags.

Also considering making the first element of the comma separated list output as the heading for the following info as this would make the output of custom data a little more flexible.

Offline

 

#5 04-25-2017 08:34:21

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19798
Website

Re: Add Shipping Cost Indications to Product Offer Display

Check this out, might give you an idea on how to better save your data:

https://forum.kryptronic.com/viewtopic.php?id=33464


Nick Hendler

Offline

 

#6 04-26-2017 06:19:38

robprotronica
Member
Registered: 12-16-2008
Posts: 106

Re: Add Shipping Cost Indications to Product Offer Display

Hi Nick,

Thanks for posting the info on handling custom data - very useful and allows the data to be put in in a more readable friendly way.

Offline

 

#7 04-26-2017 07:22:53

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19798
Website

Re: Add Shipping Cost Indications to Product Offer Display

No problem.  If you need anything else like that, let me know.  I'm going to be writing a bunch of developer documentation over the next few months, so just ask for what you want.


Nick Hendler

Offline

 

Board footer