Jump to content

How to display shpping price on product content page.


Recommended Posts

You say you are wanting a 'static value' to show shipping costs.


I will recommend this mod:



You can easily add (static) fields for shipping costs, shipping lead time, and all manner of details that would be stored with each product.


(Unfortunately, because Chuggy is no longer a Commercial Member at www.cubecartforums.org, valuable information on how to easily setup and use this mod is no longer available. But I should be able to reproduce the instructions. --Yes, in fact, I saved the forum conversation.)

Link to comment
Share on other sites

CubeCart has a shipping module, By Weight, that will store your shipping rates. Since this does not change, and the product's weight is known when CubeCart is showing the product details, adding code to fetch the rate should be easy.


The rates you enter are stored in the database, in the 'By_Weight' record of the CubeCart_modules table.


I will have a solution shortly.

Link to comment
Share on other sites

Thanks for reply.


I know By_Weight record store in CubeCart_modules tables.

But i want the admin in set or enter :=

1st Class Shipping Rates : 0.25:29,0.5:38,1:49,10:58,30:89

2st Class Shipping Rates : 0:156,5:156,10:188,15:220,20:252,25:284,30:316,40:495,49:795,70:995,100:1495,600:3195


This value how to get in Content.product.php


Please help me.

Link to comment
Share on other sites

We are going to try the following solution by using a Code Snippet. These conditions apply:

* The Customer must be logged in.

* The customer must have at least one address in their address book, of which it is marked as 'default'.

* The By Weight shipping module must have country ISO codes entered in the applicable zone blocks.


In admin, Manage Hooks, Code Snippets tab, click Add Snippet. Fill in the following fields:

Enabled: Green Check

Unique ID: SonVPP@CubeCart

Execution Order: 99

Description: Provides Shipping Data for View Product Page

Trigger: class.catalogue.productassign

Version: 1.0

Author: kenhar

PHP Code:

$SonVPP['contents'][] = $product;
$SonVPP['weight'] = $product['product_weight'];
# Check if user has a default address (will check if user is logged in). If so,
if( ($SonVPP['defAddresses'] = $GLOBALS['user']->getDefaultAddress()) !== false ) {
  foreach( $SonVPP['defAddresses'] as $address ) {
    if( $address['billing'] ) { $SonVPP['billing_address'] = $address; }
    else { $SonVPP['delivery_address'] = $address; }
  # Check if By_Weight, Per_Category, AIO, By_Percent, By_Price, Flat_Rate, Per_Category, or Per_Item are enabled. If so,
  if(($SonVPP['shipping_modules'] = $GLOBALS['db']->select('CubeCart_modules', array('folder', 'countries'), array('module' => 'shipping', 'status' => '1'))) !== false) {
    foreach( $SonVPP['shipping_modules'] as $module ) {
      $module['countries'] = Config::getInstance()->get($module['folder'], 'countries');
      $SonVPP['countries'] = (!empty($module['countries'])) ? unserialize($module['countries']) : false;
      $module['disabled_countries'] = Config::getInstance()->get($module['folder'], 'disabled_countries');
      $SonVPP['disabled_countries'] = (!empty($module['disabled_countries'])) ? unserialize($module['disabled_countries']) : false;
      if( $GLOBALS['cart']->checkShippingModuleCountry($SonVPP['countries'],'enabled') || $GLOBALS['cart']->checkShippingModuleCountry($SonVPP['disabled_countries'],'disabled') ) continue;
      $SonVPP['class'] = CC_ROOT_DIR.CC_DS.'modules'.CC_DS.'shipping'.CC_DS.$module['folder'].CC_DS.'shipping.class.php';
      if( file_exists($SonVPP['class']) ) {
        // Version 5 Shipping Calculators
        // fix for duplicate shipping module entries in config table
        if( !class_exists($module['folder']) ) include $SonVPP['class'];
          // Instantiating this module's shipping class and calculating.
        if( class_exists($module['folder']) && method_exists((string)$module['folder'], 'calculate') ) {
          $SonVPP_shipping = new $module['folder']($SonVPP);
          $SonVPP['packages'] = $SonVPP_shipping->calculate();
          if( $SonVPP['packages'] ) {
            uasort( $SonVPP['packages'], 'price_sort' );
            $SonVPP['shipArray'][$module['folder']] = $SonVPP['packages'];
        } else { /* This shipping module does not have a shipping calculator. */ }
    foreach ($GLOBALS['hooks']->load('class.cart.load_shipping') as $hook) include $hook;
    if (isset($SonVPP['shipArray']) && is_array($SonVPP['shipArray'])) { /* We have a shipping array.*/
      $product['shipArray'] = $SonVPP['shipArray'];
    } else { /* No shipping option is available due to Allowed/Disabled zones restriction. */ }
  } else { /* No shipping is available due to no shipping modules found. */ }
} else { /* Failed to get addresses. */ }

You now have an array as part of the skin variable $PRODUCT array. As an example of how to use this data, in the skin template file content.product.php, enter the following code where you want the shipping cost for this product to appear:

{if $PRODUCT.shipArray}
  {foreach $PRODUCT.shipArray as $shipper => $package}
    {$shipper}: {TAX::getInstance()->priceFormat($package.0.value)}<br />

This shipping cost is for display purposes only. CubeCart will make proper shipping calculations when the customer begins to checkout.

Link to comment
Share on other sites

From the above code to add to the template:

{if $PRODUCT.shipArray}
  {foreach $PRODUCT.shipArray as $shipper => $package}
    {$shipper}: {TAX::getInstance()->priceFormat($package.0.value)}<br />

We will break out the various methods of the package:

{if $PRODUCT.shipArray}
  {foreach $PRODUCT.shipArray as $shipper => $package}
    {foreach $package as $method}{$method.name}
    TAX::getInstance()->priceFormat($method.value)}<br />
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...