ZenCart product_info.php Quantity Box - zen-cart

I'm hoping someone out there can help me with this. I tried posting it in the zencart forum, but no takers yet - so I'm hoping stackoverflow will be able to help.
In zencart, I've found that the product_info page can display minimum, maximum, and product quantity units. However, it displays it "side by side".
Click to see the image.
I would like to have it displayed as a list item instead, but I'm at a loss on how I can do this.
The furthest I've got is narrowing it down to the tpl_product_info_display.php and in it, I found that it's caused by
$the_button = zen_get_products_quantity_min_units_display((int)$_GET['products_id'])
Thank you in advance!

To those that were also wondering about this... someone managed to answer it in the zen-cart forum.
Head to includes -> Functions - Functions.php (in my case, I found it in functions_prices.php)
Then look for "zen_get_products_quantity_min_units_display" function.
Change the following:
if ($check_min != 1) {
$the_min_units .= PRODUCTS_QUANTITY_MIN_TEXT_LISTING . ' ' . $check_min;
}
To:
if ($check_min != 1) {
$the_min_units .= PRODUCTS_QUANTITY_MIN_TEXT_LISTING . ' ' . $check_min . '<br />';
}
Adding the end, simply creates a new line, getting rid of displaying the units "side by side".

Related

When using OPT-2.7B or any other natural language model, is there a way to trick it into having a conversation/ give it a pre prompt in the code

Using this code, or a variant of, is there anything that can be added to "trick" opt into conversing as another user in a style more similar to a chatbot. As of now it will either start something more similar to an article or have a conversation with itself for a few lines as seen below.
val = input("Enter your value: ")
input_ids = tokenizer((val), return_tensors='pt').input_ids
output = model.generate(input_ids, min_length=1, max_length=1024, penalty_alpha=0.6, top_k=6)
print("Output:\n" + 100 * '-')
print(tokenizer.decode(output[0], skip_special_tokens=True))
print("" + 100 * '-')
with open("OutputText.txt", "w") as f:
f.write(tokenizer.decode(output[0], skip_special_tokens=True))
Here's an example of the current output:
*User Input:
Hello There.
Model Output:
Hello there. I have an egg that matches your TSV. Would you mind hatching it for me?
Sure, I'll add you now. Let me know when you're online.
Sorry for the late reply. I'm online now for the next few hours. Just send me a trade request whenever you're ready.
No probs, I'm in the middle of a battle at the moment, but I'll get you as soon as I'm done.
Thank you very much for the hatch. Have a nice day :D
*
I've attempted to add a prompt to the start and it hasn't made a difference.

PERL | Not getting the value after second submit

everyone.
I'm doing an tool with Perl that actually verifies a status in the database and if necessary it gets the properly queries and after confirmation it updates the value.
The page has three possible contents:
If the query that will be used is already filled it updates and returns the status.
If only the serial that the user input is filled it generates the query and then asks for confirmation.
If none of those 2 variables are already filled it goes to the main form where the user can submit the serial.
The problem that I'm facing is that after it generates the $final_query and shows up for confirmation, when I click the Confirm button it reloads the page but it pass directly through the if($final_query) and even the elseif that verifies if the $serial_no is already set.
Does Perl really lose those values if I perform a second submit or am I doing something wrong?
I'd love to have some explanation about it because it's the second time that I'm doing something with that language.
Thanks in advance!
--edit
I chopped the code to show where it defines the $final_query but I kept the structure to help in the understanding.
The full code is available at http://pastebin.com/6NqhbVau
#headers
if ($final_query) {
$content = "<h1>first if</h1>";
#updateESNDatabase($database, $final_query);
#it only enters here if the user type the ESN
}elsif ($serial_no) {
#selects the database
switch(checkUpdateNeeded($database, $serial_no)) {
case 0 {
#Shows that the updates are no needed
}
case 1 {
$final_query = `cat $query1`;
chop($final_query);
$final_query =~ s/SERIALNUM/$serial_no/g;
$final_query =~ s/LOGINID/$login_id/g;
$content = $cgi->start_form .
"<center>" .
"<h3> Please double check the queries below before you update on database </h3>" .
"</center>" .
$cgi->submit("Confirm") . $cgi->end_form;
$content .= $final_query;
}
case 2 {
#Makes almost the same as the first case, it only uses a different file to generate the query.
}
}
} else {
#Generates the first page, where the users inputs information
}
$page->set_content($content);
$page->process;
I figured out how to perform this.
As per my analysis I cannot simply create a variable and pass it through the cgi form.
To workaround this what I've done is create a hidden input in HTML and then send the variable through it.
<input type='hidden' name='the_query' value=\"$final_query\">

mysql query not working - it's not selecting the table information

I have a query that is working in all my other php files but it will not work here. Can someone please look at what I have and let me know why the query is not selecting the fields?
Please keep in mind that $res is my database connection that's open, and all the table fields are spelled correctly to the table. I have tried not having those single quotes that are sideways and as you can see in the code I have tried it with them. I have also tried not having ' ' and have tried it with them. I can remark out the lines and the code works, but put them back live and the code stops working with no error given.
I don't know if this helps, but my PHP version is 5.3.3-40.el6_6
$result2 = mysqli_query($res, "SELECT pre_sponsor_sponsor, slid FROM `pres` WHERE `pre_sponsor` = '$spospo' AND `slid` = '$slid' AND `pre_id` <= '$pre_id' LIMIT 1");
$row2 = mysqli_fetch_array($result2)
$spospo = $row2[pre_sponsor_sponsor];
$slid = $row2[slid];
First of all you missed semicolon at line 3.
But I think you should write
$row2 = mysqli_fetch_array($result2, MYSQLI_ASSOC);
Regards.
I see my problem after posting it here. I forgot the semi-colon after the $row2 = mysqli_fetch_array($result2) - it should have a ; after it.
Sorry for posting this.

.bindpopup function is not working for displaying a large amount of points onto a map (Leaflet)

I am trying to make use of the bindpopup function to display more than 100 points on a map, but the function is not working as expected. The points are added without any error on the map but when it comes to adding the .bindpopup function, no map is being rendered, blank screen. The code below is when i am looping into an array to retrieve the coordinates for display and their corresponding information placed into a popup.
for($i=0;$i<sizeof($result);$i++){
if(!empty($result[$i])){
foreach($result[$i] as $r){
$info = "";
foreach($r->info as $eachInfo){
$info .= $eachInfo . "<br/>";
};
echo "
var mark = L.marker([" . $r->coordinates[0]->longitude . "," . $r->coordinates[0]->latitude . "]);
var popup = L.popup().setContent('".$info."');
mark.addTo(map);
mark.bindPopup(popup);
";
}
}
}
If i remove/comment the popup part above, i get all the points being displayed on the map, the problem occurs when there is a large number of points to be displayed (above 100 possibly) while using the .bindpopup function
Is there a solution to overcome this particular problem?
Thanks for helping
First off make sure the problem isn't in your PHP script by making sure error_reporting and display_errors are turned on, see:
http://php.net/manual/en/function.error-reporting.php
http://php.net/manual/en/errorfunc.configuration.php#ini.display-errors
If there's no problem then you'll come to find out that the problem isn't in the amount of markers, you can easily test that by setting a static text as popup content:
var popup = L.popup().setContent('Test one two!');
You'll see that works. You'll come to find out that somewhere in one (or more) of your $info entries there's a single quote '; That will render your output javascript like this:
var popup = L.popup().setContent('OMG here's an error!');
That will fail horribly. The solution here is too escape all the single quotes in the $info strings. How you do that depends on the contents of $info entries but there is more than enough to be found on SO like here for instance:
How to escape only single quotes?
Offtopic tip:
You don't need to create a seperate popup if you're doing nothing else than setting it's contents, you can just use bindPopup on the marker object and it will do that for you:
var mark = L.marker([" . $r->coordinates[0]->longitude . "," . $r->coordinates[0]->latitude . "])
.bindPopup('".$info."')
.addTo(map);
Reference: http://leafletjs.com/reference.html#marker-bindpopup

Can't get Xpath to only output some TD's

It's probably really easy if you know how, but I don't, and after spending hours Googling it I have to ask some "real" programmers, as I'm obviously not one.
I can't seem to find a tutorial or a code example that'll work for me. Let's say I just wanted to output the "EuroDiesel 10" TR (scroll halfway down to find it) and then I only want data from TD number 1 and 9. How would I go about doing that?
I also want to add the output data to a SQL DB with a date stamp as well as update it once a day. I assume this can be done with a Cron Job, is this correct and should a make a job for each price list I want to harvest data from or could I do it in a single script (the sites are very different)?
First of all I just need the correct data. This is what I got so far.
<?php
$dom = new DOMDocument;
$date = date("j. F, Y");
libxml_use_internal_errors(true);
$dom->loadHTMLFile('http://www3.statoil.com/mar/kbh00438.nsf/UNID/8C81E46A6EC8BA3BC12578C0002FFF5A?OpenDocument');
libxml_use_internal_errors(false);
$xpath = new DOMXPath($dom);
$aTag = $xpath->query('//p[#class="text"]');
foreach($aTag as $val) {
echo $date, '', $val->plaintext. "". utf8_decode(trim($val->nodeValue, "")) . "<br />\n";
}
?>
I hope you guys can help me out, just learning here...
Thanks!
Art
As for the XPath, I think /html/body/form/table/tbody/tr[normalize-space(td[1]) = 'EuroDiesel 10']/td[position() = 1 or position() = 9] should do. Then access $val->textContent instead of nodeValue.