Forums / Addon Shipping Modules / Making Amendments To Big Royal Mail Contribution - Need Guidance

Making Amendments To Big Royal Mail Contribution - Need Guidance

Locked

Views: 1,912

Results 1 to 14 of 14
This thread is locked. New replies are disabled.
18 Oct 2008, 8:11 PM
#1
some_name_not_taken avatar

some_name_not_taken

Zen Follower

Join Date:
Sep 2008
Posts:
106
Plugin Contributions:
0

Making Amendments To Big Royal Mail Contribution - Need Guidance

I am trying to amend the Big Royal Mail Contribution to add some missed functionality and need some advice on which files I should be amending.

What I am wanting to do is to add a length and width field to the product description and to then add additional code to the BRM mod so it will filter items to be posted by width and length, not just weight. For myself I only need this to be applied to letter and large letter post because both have a width and length limit.

An alternative to this would be to add the option to "turn off" some postage options in each product description and to then pass those not values to the BRM mod following purchase, which I think is likely to be allot harder than the first option, not least because in the first there is existing code that should just need some expansion.

If anyone has any suggestions I would be most interested to hear them, because at the moment I really am not at all certain which files I should be modifying and would like to keep this as straightforward as possible.

18 Oct 2008, 8:43 PM
#2
some_name_not_taken avatar

some_name_not_taken

Zen Follower

Join Date:
Sep 2008
Posts:
106
Plugin Contributions:
0

Re: Making Amendments To Big Royal Mail Contribution - Need Guidance

I think, looking through the Admin configuration, that I can add length and width values using the Option... options under Catalog, so, if this is so, that would sort adding the required values to the product...

18 Oct 2008, 10:30 PM
#3
some_name_not_taken avatar

some_name_not_taken

Zen Follower

Join Date:
Sep 2008
Posts:
106
Plugin Contributions:
0

Re: Making Amendments To Big Royal Mail Contribution - Need Guidance

Forget the Option... options under Catalog - they don't do anything for you unless you are wanting to sell a range of coloured T-shirts or the like - anything else just produces a whole shed load of stupid error messages.

:censored:

Guess it's time to rewrite the files again...

18 Oct 2008, 11:14 PM
#4
some_name_not_taken avatar

some_name_not_taken

Zen Follower

Join Date:
Sep 2008
Posts:
106
Plugin Contributions:
0

Re: Making Amendments To Big Royal Mail Contribution - Need Guidance

The attribute additions do work, but they are for displaying more info on the product listings themselves, not for admin or product type additions... and under the Attributes Controller, where it says Adding New Attributes, you need to click on the title under option name (so it is highlighted) otherwise clicking on the insert button won't insert the attribute.

19 Oct 2008, 12:33 AM
#5
some_name_not_taken avatar

some_name_not_taken

Zen Follower

Join Date:
Sep 2008
Posts:
106
Plugin Contributions:
0

Re: Making Amendments To Big Royal Mail Contribution - Need Guidance

Right, I have now got Length and Width showing under Product Types - Product General, with True/False value selectors.

For anyone following this, this was achieved through two database modifications, which basically involved little more than copying the line for product weight, and changing the details to show length and width in place of weight.

I am now hacking a few files to make the amendments usuable...

19 Oct 2008, 1:58 AM
#6
some_name_not_taken avatar

some_name_not_taken

Zen Follower

Join Date:
Sep 2008
Posts:
106
Plugin Contributions:
0

Re: Making Amendments To Big Royal Mail Contribution - Need Guidance

Four entries required in SQL, not two, and I now have a problem with main_template_vars.php:

  // This should be first line of the script:
  $zco_notifier->notify('NOTIFY_MAIN_TEMPLATE_VARS_START_PRODUCT_INFO');

  $module_show_categories = PRODUCT_INFO_CATEGORIES;

  $sql = "select count(*) as total
          from " . TABLE_PRODUCTS . " p, " .
                   TABLE_PRODUCTS_DESCRIPTION . " pd
          where    p.products_status = '1'
          and      p.products_id = '" . (int)$_GET['products_id'] . "'
          and      pd.products_id = p.products_id
          and      pd.language_id = '" . (int)$_SESSION['languages_id'] . "'";


  $res = $db->Execute($sql);

  if ( $res->fields['total'] < 1 ) {

    $tpl_page_body = '/tpl_product_info_noproduct.php';

  } else {

    $tpl_page_body = '/tpl_product_info_display.php';

    $sql = "update " . TABLE_PRODUCTS_DESCRIPTION . "
            set        products_viewed = products_viewed+1
            where      products_id = '" . (int)$_GET['products_id'] . "'
            and        language_id = '" . (int)$_SESSION['languages_id'] . "'";

    $res = $db->Execute($sql);

    $sql = "select p.products_id, pd.products_name,
                  pd.products_description, p.products_model,
                  p.products_quantity, p.products_image,
                  pd.products_url, p.products_price,
                  p.products_tax_class_id, p.products_date_added,
                  p.products_date_available, p.manufacturers_id, p.products_quantity,
                  p.products_weight, p.products_priced_by_attribute, p.product_is_free,
		  p.products_length, p.products_priced_by_attribute, p.product_is_free,
                  p.products_qty_box_status,
                  p.products_quantity_order_max,
                  p.products_discount_type, p.products_discount_type_from, p.products_sort_order, p.products_price_sorter
           from   " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
           where  p.products_status = '1'
           and    p.products_id = '" . (int)$_GET['products_id'] . "'
           and    pd.products_id = p.products_id
           and    pd.language_id = '" . (int)$_SESSION['languages_id'] . "'";

    $product_info = $db->Execute($sql);

    $products_price_sorter = $product_info->fields['products_price_sorter'];

    $products_price = $currencies->display_price($product_info->fields['products_price'],
                      zen_get_tax_rate($product_info->fields['products_tax_class_id']));

    $manufacturers_name= zen_get_products_manufacturers_name((int)$_GET['products_id']);

    if ($new_price = zen_get_products_special_price($product_info->fields['products_id'])) {

      $specials_price = $currencies->display_price($new_price,
                        zen_get_tax_rate($product_info->fields['products_tax_class_id']));

    }

The addition of this line:

		  p.products_length, p.products_priced_by_attribute, p.product_is_free,

seems to be behind this problem:

1054 Unknown column 'p.products_length' in 'field list'
in:
[select p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id, p.products_quantity, p.products_weight, p.products_priced_by_attribute, p.product_is_free, p.products_length, p.products_priced_by_attribute, p.product_is_free, p.products_qty_box_status, p.products_quantity_order_max, p.products_discount_type, p.products_discount_type_from, p.products_sort_order, p.products_price_sorter from products p, products_description pd where p.products_status = '1' and p.products_id = '5' and pd.products_id = p.products_id and pd.language_id = '1']

...which wouldn't be a problem if I could work out what needs to be fixed/amended/updated in order to fix it...

19 Oct 2008, 3:42 AM
#7
some_name_not_taken avatar

some_name_not_taken

Zen Follower

Join Date:
Sep 2008
Posts:
106
Plugin Contributions:
0

Re: Making Amendments To Big Royal Mail Contribution - Need Guidance

I am now certain that the problem with

1054 Unknown column 'p.products_length' in 'field list'
in:
[select p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id, p.products_quantity, p.products_weight, p.products_length, p.products_width, p.products_priced_by_attribute, p.product_is_free, p.products_length, p.products_priced_by_attribute, p.product_is_free, p.products_qty_box_status, p.products_quantity_order_max, p.products_discount_type, p.products_discount_type_from, p.products_sort_order, p.products_price_sorter from products p, products_description pd where p.products_status = '1' and p.products_id = '6' and pd.products_id = p.products_id and pd.language_id = '1']

when I try to view my products in normal store format is connected to Admin -> categories.php... and from there the database.

The snag is that I cannot identify which values the categories.php is referencing in the database and the search feature of MyPHP is worse than useless for this kind of problem.

19 Oct 2008, 5:17 AM
#8
chuck avatar

chuck

Totally Zenned

Join Date:
Jul 2005
Posts:
255
Plugin Contributions:
0

Re: Making Amendments To Big Royal Mail Contribution - Need Guidance

I remember seeing a shipping mod, I think it was canada post, that added width/height/length fields to the database. Might it be worth a look for inspiration?

19 Oct 2008, 5:29 AM
#9
some_name_not_taken avatar

some_name_not_taken

Zen Follower

Join Date:
Sep 2008
Posts:
106
Plugin Contributions:
0

Re: Making Amendments To Big Royal Mail Contribution - Need Guidance

Found the database, but that is as far as I can take this unless someone can help with this thread. - Thanks for the advice Chuck I will take a look at that now.

The current problem is that I have a buggy version of MySQL that will not allow the creation of new fields no matter what, so I need a workaround.

The code I have been trying to use is as follows:

INSERT INTO products (Field, Type, Collation, Attributes, Null, Default)
VALUES (1, 'products_length', 'float', '', '', 0), (2, 'products_width', 'float', '', '', 0) 

and is intended to be input into the products table.

The 'manual' for MySQL makes it quite obvious that my version of MySQL is shot to hell or the above code would work, so this is as far as things can go unless there is a workaround somewhere...

19 Oct 2008, 5:40 AM
#10
some_name_not_taken avatar

some_name_not_taken

Zen Follower

Join Date:
Sep 2008
Posts:
106
Plugin Contributions:
0

Re: Making Amendments To Big Royal Mail Contribution - Need Guidance

Chuck, you wouldn't happen to remember any further details about the Canada mod, would you?

I have found what must be close on 500 posts and many of them are very long threads...

19 Oct 2008, 6:24 AM
#11
some_name_not_taken avatar

some_name_not_taken

Zen Follower

Join Date:
Sep 2008
Posts:
106
Plugin Contributions:
0

Re: Making Amendments To Big Royal Mail Contribution - Need Guidance

I've found the post, Chuck, and it really helped - thanks!

The additions to the products table needed to be made using ALTER TABLE.

Everything looks to be working now, except that I now have

TEXT_PRODUCTS_LENGTH
TEXT_PRODUCTS_WIDTH

on the Admin product listing pages in place of

Product Length
Product Width

and

** * TEXT_PRODUCT_LENGTH12TEXT_PRODUCT_LENGTH_UNIT
* TEXT_PRODUCT_WIDTH12TEXT_PRODUCT_WIDTH_UNIT**

in the store in place of the above with their respective values.

I don't know why this is yet.

19 Oct 2008, 6:34 AM
#12
some_name_not_taken avatar

some_name_not_taken

Zen Follower

Join Date:
Sep 2008
Posts:
106
Plugin Contributions:
0

Re: Making Amendments To Big Royal Mail Contribution - Need Guidance

The TEXT_PRODUCT_WIDTH_LENGTH is connected to this code

<?php echo (($flag_show_product_info_width == 1 and $products_width !=0) ? '<li>' . TEXT_PRODUCT_WIDTH . $products_width . TEXT_PRODUCT_WIDTH_UNIT . '</li>' : '') . "\n"; ?> 

but I do not see why it should be displaying the text, not just generating a value and leaving things at that...

...unless the . TEXT_PRODUCT_WIDTH_UNIT . would normally be replaced by something (eg: cm, mm, m, etc.)... and I am not sure how to define and link them into the code.

19 Oct 2008, 7:11 PM
#13
some_name_not_taken avatar

some_name_not_taken

Zen Follower

Join Date:
Sep 2008
Posts:
106
Plugin Contributions:
0

Re: Making Amendments To Big Royal Mail Contribution - Need Guidance

Yes, TEXT_PRODUCT_WIDTH_UNIT is the unit of measurement, weight, etc. and TEXT_PRODUCT_WIDTH just required an entry in one of the language files.

The only snag is that when I set the values for the product they are not updated in the database...

19 Oct 2008, 8:42 PM
#14
some_name_not_taken avatar

some_name_not_taken

Zen Follower

Join Date:
Sep 2008
Posts:
106
Plugin Contributions:
0

Re: Making Amendments To Big Royal Mail Contribution - Need Guidance

Well I'm leaving this as it is. - It is obvious there is no interest in trying to update the module to acknowledge length and width limits and there is no way that Zen Cart will allow the working addition of length and width variables.

Even if you manage to add the variables and make them configurable it is not possible to change any of the values from the default values.

So one day perhaps Zen Cart will support additional variables properly without having to do a major rewrite of half the files and we may get this additional functionality added to the BRM module but until then I'm more inclined than ever to simply go commercial.