Zen Cart Logo
Forums / General Questions / A few questions

A few questions

Locked

Views: 7,913

Results 21 to 40 of 45
This thread is locked. New replies are disabled.
18 Aug 2006, 2:34 PM
#21
businessman332211 avatar

businessman332211

New Zenner

Join Date:
Aug 2006
Posts:
35
Plugin Contributions:
0

A few questions

Ok I understood that so far, but can you explain it a little more, if I am not careful, see with me, I always build stuff from scratch, this is my first time working on a third party system, but my experience is allowing me to, once I find the files, I know of 10-20 ways I would normally do this on my own system, but I don't know the large system, and I know on a system like this, 1 misprint code, could mess up a large portion of the functionality, I want to be very careful, as for the styling thing, I already got that situated.

18 Aug 2006, 2:41 PM
#22
businessman332211 avatar

businessman332211

New Zenner

Join Date:
Aug 2006
Posts:
35
Plugin Contributions:
0

Re: A few questions

Ok, now that I stood back and see what I need, I need help doing 2 things.

  1. Getting a link to appear, based on what attribute is there.

  2. Getting to the point, ok we create an attribute, it has a text field, we created this of course using the admin, we need to be able get it to where, the idea is a link appears next to the page. Ok, next to that attribute I mean, then they click the link it takes them to the color pallete. They pick a color, then on the actually color pallete, it has a link going back to the previous page, with a get query that have the information on the color they chose. After they chose the color and click the url, it takes them back to the page they came from, and is suppose to populate that text field, that will allow it to carry the number over into the shoping cart without us having to do anything manually.

18 Aug 2006, 2:45 PM
#23
businessman332211 avatar

businessman332211

New Zenner

Join Date:
Aug 2006
Posts:
35
Plugin Contributions:
0

Re: A few questions

  1. you can create an extra field in your product attributes table, and then output that alongside the $options_menu[]
    Can you explain a little more on what you mean by that actually, I think that will solve my problem on the links once I understand that completely. As for getting the link to populate that field, I can tackle that once I get the theory down on getting links to appear based on attribute.
18 Aug 2006, 2:55 PM
#24
businessman332211 avatar

businessman332211

New Zenner

Join Date:
Aug 2006
Posts:
35
Plugin Contributions:
0

Re: A few questions

That sounds logical, but this is what I need.
We have a field called chooselaminate or something, it has a text field, we need to have that, wherever it shows that attribute, it shows a link, above or below it.
Then I can populate the text field, with the results when the link comes back. Now as far as it goes with the others, he might have an other text box called something else, but he needs another"different" link to appear where all of those go, he might have like 4-5 different attributes, and each attribute type is going to need a different url to appear with it wherever that attribute it.

18 Aug 2006, 2:57 PM
#25
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: A few questions

The attributes module I mentioned -- that's where you'll have to build this. Lotsa fun.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

18 Aug 2006, 2:59 PM
#26
businessman332211 avatar

businessman332211

New Zenner

Join Date:
Aug 2006
Posts:
35
Plugin Contributions:
0

Re: A few questions

building it is fine, I just have to understand the concept. You mentioned something about creating a table, and outputing it beside teh field, on that page, can you give me a little background on that process if you have used it before, as far as populating the text field with the get return from that url, do you know where I can find the text field to set that up.

18 Aug 2006, 3:08 PM
#27
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: A few questions

i don't recall mentioning any table.

But as for text fields, the attribute text fields are built dynamically, and are numbered according to sort orders specified when creating them in the admin area.
So, to find out the name or id of the text field in order to have a javascript tool update said field, open the product page in your browser, use View Source to see all the field names associated with the desired attribute, and use that information to build your linkage.

Attribute information is not passed via GET ... it uses POST, so you will have to get creative in order to pass the updates. Hence the mention of javascript ... which would only be useful if your laminates page was a popup...

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

18 Aug 2006, 3:14 PM
#28
businessman332211 avatar

businessman332211

New Zenner

Join Date:
Aug 2006
Posts:
35
Plugin Contributions:
0

Re: A few questions

Ok, I had some usage with the id's when I was setting the styles. But I am a little confused, I have 2 files, the tpl_module_attributes.php and attributes.php
the tpl_module_attributes.php I know displays all the information, the attributes.php is the page that prepares all the information to display. What you said sounded logical, to get javascript to open a window, and everything, but I think I am still missing something. Can you explain to me one more time, about getting a link to appear based on what attribute is there. I am still a little confused. I guess more of on the system, I know my way around quite a bit, and I learn very fast, very fast, that is why I am getting on so quickly, but I am a little hazy on this part still. As far as populating the text field, so there is no way to get direct access to the input tag that contains that text field? A little more clarification on a few more things and I think I will be good to go.

18 Aug 2006, 3:15 PM
#29
businessman332211 avatar

businessman332211

New Zenner

Join Date:
Aug 2006
Posts:
35
Plugin Contributions:
0

Re: A few questions

1. you can create an extra field in your product attributes table, and then output that alongside the $options_menu[]

2. put a switch statement alongside the $options_menu[] echo statement.

That is where table was mentioned, it was posted by someone else shortly after you posted that one.

18 Aug 2006, 3:26 PM
#30
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: A few questions

A little visit in to the code in attributes.php shows this, starting on line 383.
The logic loops through a few possible attribute settings as defined in the admin interface in order to determine how to display the text field, and then builds the <INPUT...> tag for it, using zen_draw_input_field().

If you want to detect a specific attribute, simply catch it in the loop and do whatever extra you desire to the output string.

                  // text
                  if (($products_options_names->fields['products_options_type'] == PRODUCTS_OPTIONS_TYPE_TEXT)) {
                    //CLR 030714 Add logic for text option
                    //            $products_attribs_query = zen_db_query("select distinct patrib.options_values_price, patrib.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$_GET['products_id'] . "' and patrib.options_id = '" . $products_options_name['products_options_id'] . "'");
                    //            $products_attribs_array = zen_db_fetch_array($products_attribs_query);
                    if ($_POST['id']) {
                      reset($_POST['id']);
                      foreach ($_POST['id'] as $key => $value) {
                        //echo ereg_replace('txt_', '', $key) . '#';
                        //print_r($_POST['id']);
                        //echo $products_options_names->fields['products_options_id'].'|';
                        //echo $value.'|';
                        //echo $products_options->fields['products_options_values_id'].'#';
                        if ((ereg_replace('txt_', '', $key) == $products_options_names->fields['products_options_id'])) {
                          // use text area or input box based on setting of products_options_rows in the products_options table
                          if ( $products_options_names->fields['products_options_rows'] > 1) {
                            $tmp_html = '  <input disabled="disabled" type="text" name="remaining' . TEXT_PREFIX . $products_options_names->fields['products_options_id'] . '" size="3" maxlength="3" value="' . $products_options_names->fields['products_options_length'] . '" /> ' . TEXT_MAXIMUM_CHARACTERS_ALLOWED . '<br />';
                            $tmp_html .= '<textarea class="attribsTextarea" name="id[' . TEXT_PREFIX . $products_options_names->fields['products_options_id'] . ']" rows="' . $products_options_names->fields['products_options_rows'] . '" cols="' . $products_options_names->fields['products_options_size'] . '" onKeyDown="characterCount(this.form[\'' . 'id[' . TEXT_PREFIX . $products_options_names->fields['products_options_id'] . ']\'],this.form.' . TEXT_REMAINING . TEXT_PREFIX . $products_options_names->fields['products_options_id'] . ',' . $products_options_names->fields['products_options_length'] . ');" onKeyUp="characterCount(this.form[\'' . 'id[' . TEXT_PREFIX . $products_options_names->fields['products_options_id'] . ']\'],this.form.' . TEXT_REMAINING . TEXT_PREFIX . $products_options_names->fields['products_options_id'] . ',' . $products_options_names->fields['products_options_length'] . ');" id="' . 'attrib-' . $products_options_names->fields['products_options_id'] . '-' . $products_options_value_id . '" >' . stripslashes($value) .'</textarea>' . "\n";
                          } else {
                            $tmp_html = '<input type="text" name="id[' . TEXT_PREFIX . $products_options_names->fields['products_options_id'] . ']" size="' . $products_options_names->fields['products_options_size'] .'" maxlength="' . $products_options_names->fields['products_options_length'] . '" value="' . stripslashes($value) .'" id="' . 'attrib-' . $products_options_names->fields['products_options_id'] . '-' . $products_options_value_id . '" />  ';
                          }
                          $tmp_html .= $products_options_details;
                          break;
                        }
                      }
                    } else {
                      $tmp_value = $_SESSION['cart']->contents[$_GET['products_id']]['attributes_values'][$products_options_names->fields['products_options_id']];
                      // use text area or input box based on setting of products_options_rows in the products_options table
                      if ( $products_options_names->fields['products_options_rows'] > 1 ) {
                        $tmp_html = '  <input disabled="disabled" type="text" name="remaining' . TEXT_PREFIX . $products_options_names->fields['products_options_id'] . '" size="3" maxlength="3" value="' . $products_options_names->fields['products_options_length'] . '" /> ' . TEXT_MAXIMUM_CHARACTERS_ALLOWED . '<br />';
                        $tmp_html .= '<textarea class="attribsTextarea" name="id[' . TEXT_PREFIX . $products_options_names->fields['products_options_id'] . ']" rows="' . $products_options_names->fields['products_options_rows'] . '" cols="' . $products_options_names->fields['products_options_size'] . '" onkeydown="characterCount(this.form[\'' . 'id[' . TEXT_PREFIX . $products_options_names->fields['products_options_id'] . ']\'],this.form.' . TEXT_REMAINING . TEXT_PREFIX . $products_options_names->fields['products_options_id'] . ',' . $products_options_names->fields['products_options_length'] . ');" onkeyup="characterCount(this.form[\'' . 'id[' . TEXT_PREFIX . $products_options_names->fields['products_options_id'] . ']\'],this.form.' . TEXT_REMAINING . TEXT_PREFIX . $products_options_names->fields['products_options_id'] . ',' . $products_options_names->fields['products_options_length'] . ');" id="' . 'attrib-' . $products_options_names->fields['products_options_id'] . '-' . $products_options_value_id . '" >' . stripslashes($tmp_value) .'</textarea>' . "\n";
                        //                $tmp_html .= '  <input type="reset">';
                      } else {
                        $tmp_html = '<input type="text" name="id[' . TEXT_PREFIX . $products_options_names->fields['products_options_id'] . ']" size="' . $products_options_names->fields['products_options_size'] .'" maxlength="' . $products_options_names->fields['products_options_length'] . '" value="' . htmlspecialchars($tmp_value) .'" id="' . 'attrib-' . $products_options_names->fields['products_options_id'] . '-' . $products_options_value_id . '" />  ';
                      }
                      $tmp_html .= $products_options_details;
                      $tmp_word_cnt_string = '';
                      // calculate word charges
                      $tmp_word_cnt =0;
                      $tmp_word_cnt_string = $_SESSION['cart']->contents[$_GET['products_id']]['attributes_values'][$products_options_names->fields['products_options_id']];
                      $tmp_word_cnt = zen_get_word_count($tmp_word_cnt_string, $products_options->fields['attributes_price_words_free']);
                      $tmp_word_price = zen_get_word_count_price($tmp_word_cnt_string, $products_options->fields['attributes_price_words_free'], $products_options->fields['attributes_price_words']);

                      if ($products_options->fields['attributes_price_words'] != 0) {
                        $tmp_html .= TEXT_PER_WORD . $currencies->display_price($products_options->fields['attributes_price_words'], zen_get_tax_rate($product_info->fields['products_tax_class_id'])) . ($products_options->fields['attributes_price_words_free'] !=0 ? TEXT_WORDS_FREE . $products_options->fields['attributes_price_words_free'] : '');
                      }
                      if ($tmp_word_cnt != 0 and $tmp_word_price != 0) {
                        $tmp_word_price = $currencies->display_price($tmp_word_price, zen_get_tax_rate($product_info->fields['products_tax_class_id']));
                        $tmp_html = $tmp_html . '<br />' . TEXT_CHARGES_WORD . ' ' . $tmp_word_cnt . ' = ' . $tmp_word_price;
                      }
                      // calculate letter charges
                      $tmp_letters_cnt =0;
                      $tmp_letters_cnt_string = $_SESSION['cart']->contents[$_GET['products_id']]['attributes_values'][$products_options_names->fields['products_options_id']];
                      $tmp_letters_cnt = zen_get_letters_count($tmp_letters_cnt_string, $products_options->fields['attributes_price_letters_free']);
                      $tmp_letters_price = zen_get_letters_count_price($tmp_letters_cnt_string, $products_options->fields['attributes_price_letters_free'], $products_options->fields['attributes_price_letters']);

                      if ($products_options->fields['attributes_price_letters'] != 0) {
                        $tmp_html .= TEXT_PER_LETTER . $currencies->display_price($products_options->fields['attributes_price_letters'], zen_get_tax_rate($product_info->fields['products_tax_class_id'])) . ($products_options->fields['attributes_price_letters_free'] !=0 ? TEXT_LETTERS_FREE . $products_options->fields['attributes_price_letters_free'] : '');
                      }
                      if ($tmp_letters_cnt != 0 and $tmp_letters_price != 0) {
                        $tmp_letters_price = $currencies->display_price($tmp_letters_price, zen_get_tax_rate($product_info->fields['products_tax_class_id']));
                        $tmp_html = $tmp_html . '<br />' . TEXT_CHARGES_LETTERS . ' ' . $tmp_letters_cnt . ' = ' . $tmp_letters_price;
                      }
                      $tmp_html .= "\n";
                    }
                  }

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

18 Aug 2006, 3:37 PM
#31
businessman332211 avatar

businessman332211

New Zenner

Join Date:
Aug 2006
Posts:
35
Plugin Contributions:
0

Re: A few questions

Ok that will be my second attempt. As for my 1st attempt, I am trying to get this right, but it's giving me difficulties, I was trying to put some scripts in the other attributes page, but It is reading it, but not giving an output, I am trying to put an if statement in php to check the name, then from that name, I think I like your advice, on that page I am going to do that, I will use javascript to create the link, as well as create the popup window, when they close the window I will have javascript populate it, that will take care of all occurences of that. I think, hmm. This might get deeper than I thought, as far as php, is there a way I can get it to display using code on the
tpl_modules_attributes.php
page I wanted to put an if statement, but I don't know what to check for, for the option_name, or option_
here is an example
The first 3 lines i what they already had, my code is below that, but not producing any output, I copied and pasted it from the source code so it should have matched, the variables. for that attribute only, but it doesn't work for anything.

<div class="wrapperAttribsOptions">
<h4 class="optionName back"><?php echo $options_name[$i] ; ?></h4>
<div class="back"><?php echo $options_menu[$i]; ?></div>
<?php
if ($options_name[$i] == "<label class=\"attribsInput\" for=\"attrib-60-285\">Custom Laminate:</label></h4>") {
?>
<br />
<a href="../../../wilsonart.php" title="Wilson Art">Choose Color!</a>
<?php
}
?>

Once I get the url's to display dynamically I can move onto the second part, is there a way I can work this into what I have, to make it show the links, then I can reproduce this code, to show links for more variety of attributes, then even setup a switch statement to make the code shorter. That will eliminate my first problem.
I can set up a case to show a specific link for each condition, then if there are more than one attribute that needs links it will also show them all, but first I have to figure out how to get one to display?

18 Aug 2006, 3:39 PM
#32
businessman332211 avatar

businessman332211

New Zenner

Join Date:
Aug 2006
Posts:
35
Plugin Contributions:
0

Re: A few questions

I also tried a few varieties of this to try and get it to display but nothing is displaying it under that link.

18 Aug 2006, 3:41 PM
#33
businessman332211 avatar

businessman332211

New Zenner

Join Date:
Aug 2006
Posts:
35
Plugin Contributions:
0

Re: A few questions

actually wait, I got it to display, I had it typed a little bit wrong, first question, is this a safe, and reliable method, here is my code for getting it to display, I could reproduce this to get them to display properly for all of them, is it reliable.

<div class="wrapperAttribsOptions">
<h4 class="optionName back"><?php echo $options_name[$i] ; ?></h4>
<div class="back"><?php echo $options_menu[$i]; ?></div>
<?php
// start my code below here
if ($options_name[$i] == "<label class=\"attribsInput\" for=\"attrib-60-285\">Custom Laminate:</label>") {
?>
<br />
<a href="../../../wilsonart.php" title="Wilson Art">Choose Color!</a>
<?php
}
// end my code.
?>
18 Aug 2006, 3:55 PM
#34
businessman332211 avatar

businessman332211

New Zenner

Join Date:
Aug 2006
Posts:
35
Plugin Contributions:
0

Re: A few questions

Ok If this is safe, I have ti handling everything, can someone please tell me real quick whether this is safe to use or not. It seems to work, I have it going to the other page, passing the url information with it, then coming back onto the page with products carrying that data with it as well, the only other thing I need is to get it to display in the text field, am I on the right track.???

18 Aug 2006, 4:09 PM
#35
businessman332211 avatar

businessman332211

New Zenner

Join Date:
Aug 2006
Posts:
35
Plugin Contributions:
0

Re: A few questions

Ok everything is done, the whole system is complete but 2 things. I need advice on 2 things now, if someone can.

  1. I need to find out, is the system I showed safe, I think it is, I just want to make sure it won't cause problems later on.

  2. I was also wondering, does anyone have any ideas, how to populate that get query, hopefully without using javascript, I only use javascript for non-functional stuff, it has to be something where the site can still function, so I want to avoid javascript if possible.

18 Aug 2006, 4:56 PM
#36
businessman332211 avatar

businessman332211

New Zenner

Join Date:
Aug 2006
Posts:
35
Plugin Contributions:
0

Re: A few questions

Ok on both pages I have broken down the code a few times, I know the system almost backwards and forwards for this part, but I still can't seem to figure it out, that area you gave me over there will all that code, I see now is where the text stuff is generated, after going over it like 3-5 times I know the way the system works almost now, but I could probably(after awhile) get it to display what I want, but I don't see how I can later when I get more than one text field, and i need like 3-4 different value fields to display different things based on which attribute, then I will start getting in over my head.

18 Aug 2006, 5:11 PM
#37
businessman332211 avatar

businessman332211

New Zenner

Join Date:
Aug 2006
Posts:
35
Plugin Contributions:
0

Re: A few questions

or would javascript be safe to use, it's just there are so many people with older browser, or with javascript disabled.

18 Aug 2006, 5:28 PM
#38
businessman332211 avatar

businessman332211

New Zenner

Join Date:
Aug 2006
Posts:
35
Plugin Contributions:
0

Re: A few questions

$tmp_html = '<input type="text" name="id[' . TEXT_PREFIX . $products_options_names->fields['products_options_id'] . ']" size="' . $products_options_names->fields['products_options_size'] .'" maxlength="' . $products_options_names->fields['products_options_length'] . '" value="' . stripslashes($value) .'" id="' . 'attrib-' . $products_options_names->fields['products_options_id'] . '-' . $products_options_value_id . '" />  ';

I found this, I know for a fact this is where I can setup something to display what I want. I need to tell it, if it is that attribute, then display $_GET['imgnumber']
I need to set it in an if statement, so if later on down the road, if I need to, I need to be able to add more if statements, or string them to it, so in time, I will be able to continue to add new values into it? Like if it's one attribute then display this, if it's this attribute display this, then if it's none of those attributes it displays the original there which seems to be stripslashes($value) which I have no idea where it's populating that from, I could pop into that value something like $_GET['imgnumber'] and I think it would work, but then all text fields would be like that, I need it to be that only if that one is present?????

18 Aug 2006, 5:30 PM
#39
businessman332211 avatar

businessman332211

New Zenner

Join Date:
Aug 2006
Posts:
35
Plugin Contributions:
0

Re: A few questions

uh nevermind, obviously that's not the right one, I tried feeding it a few values and it didn't change it, I have to keep looking, any advice would be appreciated.

18 Aug 2006, 5:42 PM
#40
businessman332211 avatar

businessman332211

New Zenner

Join Date:
Aug 2006
Posts:
35
Plugin Contributions:
0

Re: A few questions

$tmp_html = '<input type="text" name="id[' . TEXT_PREFIX . $products_options_names->fields['products_options_id'] . ']" size="' . $products_options_names->fields['products_options_size'] .'" maxlength="' . $products_options_names->fields['products_options_length'] . '" value="' . htmlspecialchars($tmp_value) .'" id="' . 'attrib-' . $products_options_names->fields['products_options_id'] . '-' . $products_options_value_id . '" />  ';

after some more digging I found this one for sure, it's the right one this time, I changed the value inside special chars to just 3, and it appeared within it on the page, now I need to set this up, any advice, would be appreciated.