Showing Up of Product Options on Products List - x-cart

how to show product options on product list in xcart 4.4.2.Under the Men's Clothes category, in shirts, I need to show options like color,size on shirts list itself.Now currently it is in shirt details page.Can anybody help me please.

You can try this solution. This will display all options values for each products in categories specified by category IDs in array(246, 247) in the condition. You should replace it with your own category IDs (home.php?cat=XXX, XXX - it's a category ID)
Patch for products.php
## -133,6 +133,14 ##
}
+if (isset($cat) && in_array($cat, array(246, 247)) && isset($products) && !empty($active_modules['Product_Options'])) {
+ foreach ($products as $k => $v) {
+ if ('Y' == $v['is_product_options']) {
+ $products[$k]['options'] = func_get_product_classes($v['productid']);
+ }
+ }
+}
+
$smarty->assign('cat_products', isset($products) ? $products : array());
$smarty->assign('navigation_script', "home.php?cat=$cat&sort=$sort&sort_direction=$sort_direction");
?>
Patch for skin/common_files/customer/main/products_list.tpl
## -45,6 +45,10 ##
<div class="descr">{$product.descr}</div>
+ {if $active_modules.Product_Options ne ""}
+ {include file="modules/Product_Options/show_options.tpl" product_options=$product.options}
+ {/if}
+
{if $product.rating_data}
{include file="modules/Customer_Reviews/vote_bar.tpl" rating=$product.rating_data productid=$product.productid}
{/if}
skin/common_files/modules/Product_Options/show_options.tpl
{if $product_options ne ''}
<br />
{foreach from=$product_options item=v}
{if $v.options ne ''}
{$v.class|escape}:
{foreach from=$v.options item=o}
{$o.option_name|escape},
{/foreach}
{/if}
<br />
{/foreach}
{/if}

Related

Custom Repeater Template code in Ajax Load More plugin not compatible with PHP8

We are hosted by WP Engine, so I tested our dev site's compatibility with PHP8 to comply with the upcoming requirement, and ran into a problem. We have listing pages that are automatically generated using a custom coded repeater template within the Wordpress Ajax Load More plugin, in conjunction with ACF. I've picked through it line by line, but can't figure out what's causing the pages to break.
At first, when I tested PHP8 compatibility earlier this year, the repeater pages returned a fatal error. Now I get a partial listing on some, and just a Load More button on others, and the Load More button doesn't work in any instance.
Everything works just fine with PHP 7.4, FWIW.
Here is one of our listing pages for reference:
https://smartorg.com/resources/principles-strategic-portfolio-management/
Here is the custom code:
<?php
$article_link = get_permalink( $post->ID );
$article_time = get_post_meta(get_the_ID(), 'length', TRUE);
$article_time = str_replace( array("min"), '', $article_time);
$article_type = get_post_meta(get_the_ID(), 'type', TRUE);
$article_val = '';
$timer = 'min';
if($article_type == 'Article') {
$article_val = 'read';
$content = get_post_field( 'post_content', $post->ID );
$word_count = str_word_count( strip_tags( $content ) );
$Words = str_replace(' ', $word_count);
$readingtime = ceil($word_count / 280);
$timer = " min";
$totalreadingtime = $readingtime . $timer;
$article_time = $totalreadingtime;
} else if($article_type == 'Video') {
$article_val = $timer . ' watch';
} else if($article_type == 'Webinar') {
$article_val = $timer . ' watch';
} else if($article_type == 'Audio') {
$article_val = $timer . ' listen';
} else{
$article_val = '';
}
$category = get_the_category( $post->ID );
// echo $atts['is_archive'];
$yoast_meta = get_post_meta(get_the_ID(), '_yoast_wpseo_metadesc', true);
if ($yoast_meta) {
$meta = $yoast_meta;
} else{
$meta = '';
}
?>
<div class="pm-main-cont">
<div class="pm-col-1">
<div class="pm-red-box"></div>
<div class="pm-article-img">
<a href="<?php echo $article_link; ?>">
<?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' ); ?>
<img src='<?php echo $image[0]; ?>' alt="post thumbnail" />
</a>
</div>
</div>
<div class="pm-col-2">
<div class="pm-article-content">
<h5><?php echo the_title(); ?></h5>
<!-- <p><?php echo the_excerpt(); ?></p> -->
<p><?php echo $meta; ?></p>
<p class="pm-time-type"><img src="http://smartorg.com/wp-content/uploads/2020/09/<?php echo $article_type; ?>.png" alt="<?php echo $article_type; ?>-icon" />
<span><?php
echo $article_time; ?>
<?php echo $article_val; ?>
</span></p>
</div>
</div>
</div>

How change product name in admin orders prestashop

I have problem with old prestashop.
Wants to do to the name of the product is in the form of a list
attribute
br
attribute
br
...
<td><a href="index.php?tab=AdminCatalog&id_product='.$product['product_id'].'&updateproduct&token='.$tokenCatalog.'">
<span class="productName">'.$product['product_name'].'</span><br />
'.($product['product_reference'] ? $this->l('Ref:').' '.$product['product_reference'] : '')
.(($product['product_reference'] AND $product['product_supplier_reference']) ? ' / '.$product['product_supplier_reference'] : '')
.'</a></td>
Put this code at the top of your file :
$product_name = $product['product_name']
$pos = strpos($product_name, ' - ');
if($pos !== false) {
$product_name = substr_replace($product_name, '<br />', $pos, 3);
}
$product_name = str_replace(', ', '<br />', $product_name);
We replace the first ' - ' and each ', ' by a <br /> so each attributes are on a single line.
Then you can use $product_name instead of $product['product_name'] in your code :
<td><a href="index.php?tab=AdminCatalog&id_product='.$product['product_id'].'&updateproduct&token='.$tokenCatalog.'">
<span class="productName">'.$product_name.'</span><br />
'.($product['product_reference'] ? $this->l('Ref:').' '.$product['product_reference'] : '')
.(($product['product_reference'] AND $product['product_supplier_reference']) ? ' / '.$product['product_supplier_reference'] : '')
.'</a></td>

Ajax dont works populating a form

Hey anyone can help me with this problem ?
I have this issue with my code, two files:
1 - test.php
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Documento sin título</title>
<script>
var url = "getagentids.php?param=";
function handleHttpResponse() {
if (http.readyState == 4) {
results = http.responseText.split(",");
document.getElementById('formality').value = results[0];
document.getElementById('fullname').value = results[1];
document.getElementById('sex').value = results[2];
document.getElementById('id').value = results[3];
document.getElementById('joindate').value = results[4];
document.getElementById('jobtitle').value = results[5];
document.getElementById('city').value = results[6];
document.getElementById('typeofsalary').value = results[7];
document.getElementById('contract_type').value = results[8];
}
}
function getagentids() {
var idValue = document.getElementById("email").value;
var myRandom=parseInt(Math.random()*99999999); // cache buster
http.open("GET", url + escape(idValue) + "&rand=" + myRandom, true);
http.onreadystatechange = handleHttpResponse;
http.send(null);
}
function getHTTPObject() {
var xmlhttp;
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
try {
xmlhttp = new XMLHttpRequest();
} catch (e) {
xmlhttp = false;
}
}
return xmlhttp;
}
var http = getHTTPObject();
</script>
</head>
<body>
<form name="schform">
<table bgcolor="#dddddd">
<tbody>
<?php
echo $param;
include '../../../connect.php';
$db =& JFactory::getDBO();
$query = "SELECT email FROM dbemployeekpw";
$db->setQuery($query);
$result = $db->loadObjectList();
$email = $result[0];
echo " <select size='1' name='email' id='email' onChange='getagentids()' required >
<option value=''> Seleccione </option>";
foreach($result as $email)
{
echo "<option value='".$email->email."'>".$email->email."</option>";
}
echo "</select>"
?>
<tr><td>Formality</td><td><input id="formality" type="text" name="formality"></td></tr>
<tr><td>Fullname</td><td><input id="fullname" type="text" name="fullname"></td></tr>
<tr><td>Sex</td><td><input id="sex" type="text" name="sex"></td></tr>
<tr><td>Id</td><td><input id="id" type="text" name="id"></td></tr>
<tr><td>Joindate</td><td><input id="joindate" type="text" name="joindate"></td></tr>
<tr><td>Jobtitle</td><td><input id="jobtitle" type="text" name="jobtitle"></td></tr>
<tr><td>City</td><td><input id="city" type="text" name="city"></td></tr>
<tr><td>Typesalary</td><td><input id="typeofsalary" type="text" name="typeofsalary"></td></tr>
<tr><td>Contract Type</td><td><input id="contract_type" type="text" name="contract_type"> </td></tr>
<tr><td><input size="60" type="reset" value="Clear"></td><td></td>
</tr>
</tbody></table>
</form>
</body>
</html>
and..
2 - getagentids.php
<?php
//$param = $_GET["param"];
include '../../../connect.php';
$db =& JFactory::getDBO();
$query = $db->getQuery(true);
$query = "SELECT * FROM dbemployeekpw WHERE email = 'camilo.uribe#kantarworldpanel.com'";
$db->setQuery($query);
$results = $db->loadObjectList();
foreach ( $results as $result )
{
$formality = $result->formality;
$fullname = $result->fullname;
$sex = $result->sex;
$id = $result->id;
$joindate = $result->joindate;
$jobtitle = $result->jobtitle;
$city = $result->city;
$typeofsalary = $result->typeofsalary;
$contract_type = $result->contract_type;
$textout = $formality.",".$fullname.",".$sex.",".$id.",".$joindate.",".$jobtitle.",".$city.",".$typeofsalary.",".$contract_type;
}
echo $textout;
?>
But ajax dont works, only works if I put this :
$query = "SELECT * FROM dbemployeekpw WHERE email = 'camilo.uribe#kantarworldpanel.com'";
instead this:
$query = "SELECT * FROM dbemployeekpw WHERE email = '".$param."'";
But I need that the code works with second one :(
Anyone can help me with this problem ?
Thanks !!
SOLVED (works like a charm!!):
I change this:
$jinput = JFactory::getApplication()->input;
$param = $jinput->get('param', 'param', 'filter');
instead this:
$param = $_GET["param"];
and I'm still with:
$query = "SELECT * FROM dbemployeekpw WHERE email = '".$param."'";
because this code don't works for me:
$query->select($db->quoteName('*'))
->from($db->quoteName('dbemployeekpw'))
->where($db->quoteName('email') . ' = '. $db->quote($param));
Many Thanks #lodder
Before anything, lets see if the $param variable is correct and gets the value. Add the following which one the form is processed, will display the value. If the result is NULL then you firstly need to ensure you get the correct value. If you do get the correct value, then carry on reading.
Just on a side note, I would recommend looking at the following link rather than using $_GET:
http://docs.joomla.org/Retrieving_request_data_using_JInput
Lets now use up to date coding standards for you database query:
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select($db->quoteName('*'))
->from($db->quoteName('dbemployeekpw'))
->where($db->quoteName('email') . ' = '. $db->quote($param));
$db->setQuery($query);
$results = $db->loadObjectList();
Hope this helps

get category products by category id in opencart

hi i want to customize the feature module that as category is set through admin display the relevant product instead of featured module
when ever i select the category it displays category products what will be the code of controller which get category n give products array to that category
below is the view code of category select input
<td><select name="category_id">
<?php foreach($categories as $category) { ?>
<option value="<?php echo $category['category_id'];?>"><?php echo $category['name'];?></option>
<?php } ?>
</select>
$categories = $this->model_catalog_product->getProductCategories(
$this->request->get['product_id']);
foreach($categories as $category_id) {
// do something
}
Add the getProductCategories function into model/catalog/product.php
public function getProductCategories($product_id) {
$product_category_data = array();
$query = $this->db->query("SELECT * FROM " . DB_PREFIX .
"product_to_category WHERE product_id = '" . (int)$product_id . "'");
foreach ($query->rows as $result) {
$product_category_data[] = $result['category_id'];
}
return $product_category_data;
}

adding dropdown to joomla registration

I am want to add a dropdown to joomla 2.5 registration.I believe I can use sql form field type but I want that sql to return all schools of a particular city ( which is in registration form) .So question is how a sql query will accept a parameter?
You have to create one field type in the models==>fields.
for ex: create a php file as schools.php, and then include the following code.
==> schools.php(filename)
defined('JPATH_BASE') or die;
class JFormFieldSchools extends JFormField
{
protected $type = 'Schools';
protected function getInput()
{
// Initialize variables.
$html = array();
$attr = '';
// Initialize some field attributes.
$attr .= $this->element['class'] ? ' class="'.(string) $this->element['class'].'"' : '';
$attr .= ((string) $this->element['disabled'] == 'true') ? ' disabled="disabled"' : '';
$attr .= $this->element['size'] ? ' size="'.(int) $this->element['size'].'"' : '';
// Initialize JavaScript field attributes.
$attr .= $this->element['onchange'] ? ' onchange="'.(string) $this->element['onchange'].'"' : '';
// Get some field values from the form.
$contactId = (int) $this->form->getValue('id');
$categoryId = (int) $this->form->getValue('catid');
// Build the query for the ordering list.
$query = 'SELECT ordering AS value, name AS text' .
' FROM #__contact_details' .
' WHERE catid = ' . (int) $categoryId .
' ORDER BY ordering';
// Create a read-only list (no name) with a hidden input to store the value.
if ((string) $this->element['readonly'] == 'true') {
$html[] = JHtml::_('list.ordering', '', $query, trim($attr), $this->value, $contactId ? 0 : 1);
$html[] = '<input type="hidden" name="'.$this->name.'" value="'.$this->value.'"/>';
}
// Create a regular list.
else {
$html[] = JHtml::_('list.ordering', $this->name, $query, trim($attr), $this->value, $contactId ? 0 : 1);
}
return implode($html);
}
}
Then you have to change the mysql query as your needs.
If have to change on the default joomla registration page then have following path(.../com_users/models/forms/registration.xml ).
<field name="xxxxx" type="Schools"
description="COM_USERS_REGISTER_NAME_DESC"
filter="string"
label="COM_USERS_REGISTER_NAME_LABEL"
message="COM_USERS_REGISTER_NAME_MESSAGE"
required="true"
size="30" />