News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Change quantity selector?

Started by mailblade, September 24, 2017, 22:22:30 PM

Previous topic - Next topic

mailblade

Hello.

I was wondering if it's possible to change the quantity box when you add a certain product to your cart.

Currently, you have to click the "+" or "-" buttons to add or remove quantity.

Can I change this to a text value that you enter?


Any advice is appreciated :)


GJC Web Design

it is a text box

http://demo.virtuemart.net/

if yours isn't then it is your temlate
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

mailblade

Thanks a lot GJC.

Yes I think it is my template. It says "undefined" when I try and type in a value.

Thanks for the info.

Cheers

GJC Web Design

means your template is not up to date for VM version

it is a JS problem
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

mailblade

Thanks GJC.

In the "Configuration" when you go to "Tempaltes", I've changed mine to use the VirtueMart layouts and javascript. Could be a problem there.

I'll have a look, could be a clash of scripts.

Otherwise my mart is coming together nicely. Just need to change cart design and fix this issue then I'm done :)

Thanks!

mailblade

Okay I've found the issue.

When you go to "Configuration" and then "Templates", one of boxes is: "Activate CSS Styles & Javascript".

Now, when I uncheck the "Using the product Scripts" option, I can enter a number value in the "Quantity" field on my category layout. However, when I then add this product to the cart via the "Add to Cart" button, it doesn't add the product or quantity. It just stays blank.

When I activate the "Using the product Scripts" option, it goes back to showing "Undefined" once I click on the quantity field.

Anyone who's had this issue?

GJC Web Design

it is JS related.. u have a JS error somewhere.. Google js console - debug etc

without a live url no one can help
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

mailblade

Okay I've found the issue. Seems to be something with the new "product-container" class in the VirtueMart Javascript.

I made overrides for cart, category and orders(this one I haven't changed anything yet).

I'll attach a screenshot of the issue:

jenkinhill

product-container was introduced for VM3.0.18 when advice was provided on required template updates.  http://forum.virtuemart.net/index.php?topic=135402.0
Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

mailblade

Thanks JenkinHill

I still don't understand what Milbo means though.

He doesn't say where to add the code if you have overrides? Just for the "product module". What does that mean? Overrides for product only?

GJC Web Design

study the stock current templates to see where the product-container class is required

think sublayouts->products.php and details
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

mailblade

Thanks a lot for your tips.

I've found the issue though I don't know how to fix it. I've edited my "default.php" in "template/html/com_virtuemart/category" to this custom code, which I do require:


<?php
/**
*
* Show the products in a category
*
* @package VirtueMart
* @subpackage
* @author RolandD
* @author Max Milbers
* @todo add pagination
* @link http://www.virtuemart.net
* @copyright Copyright (c) 2004 - 2010 VirtueMart Team. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* VirtueMart is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* @version $Id: default.php 6053 2012-06-05 12:36:21Z Milbo $
*/

//vmdebug('$this->category',$this->category);
vmdebug('$this->category '.$this->category->category_name);
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');
JHTML::_'behavior.modal' );
/* javascript for list Slide
  Only here for the order list
  can be changed by the template maker
*/
$js "
jQuery(document).ready(function () {
jQuery('.orderlistcontainer').hover(
function() { jQuery(this).find('.orderlist').stop().show()},
function() { jQuery(this).find('.orderlist').stop().hide()}
)
});
"
;

$document JFactory::getDocument();
$document->addScriptDeclaration($js);

/*$edit_link = '';
if(!class_exists('Permissions')) require(JPATH_VM_ADMINISTRATOR.DS.'helpers'.DS.'permissions.php');
if (Permissions::getInstance()->check("admin,storeadmin")) {
$edit_link = '<a href="'.JURI::root().'index.php?option=com_virtuemart&tmpl=component&view=category&task=edit&virtuemart_category_id='.$this->category->virtuemart_category_id.'">
'.JHTML::_('image', 'images/M_images/edit.png', JText::_('COM_VIRTUEMART_PRODUCT_FORM_EDIT_PRODUCT'), array('width' => 16, 'height' => 16, 'border' => 0)).'</a>';
}

echo $edit_link; */
if ( empty($this->keyword) ) {
?>

<div class="category_description">
<?php echo $this->category->category_description ?>
</div>
<?php
}

/* Show child categories */

if ( VmConfig::get('showCategory',1) and empty($this->keyword)) {
if ($this->category->haschildren) {

// Category and Columns Counter
$iCol 1;
$iCategory 1;

// Calculating Categories Per Row
$categories_per_row VmConfig::get 'categories_per_row');
$category_cellwidth ' width'.floor 100 $categories_per_row );

// Separator
$verticalseparator " vertical-separator";
?>


<div class="category-view">

<?php // Start the Output
if(!empty($this->category->children)){
foreach ( $this->category->children as $category ) {

// Show the horizontal seperator
if ($iCol == && $iCategory $categories_per_row) { ?>

<div class="horizontal-separator"></div>
<?php }

// this is an indicator wether a row needs to be opened or not
if ($iCol == 1) { ?>

<div class="row">
<?php }

// Show the vertical seperator
if ($iCategory == $categories_per_row or $iCategory $categories_per_row == 0) {
$show_vertical_separator ' ';
} else {
$show_vertical_separator $verticalseparator;
}

// Category Link
$caturl JRoute::'index.php?option=com_virtuemart&view=category&virtuemart_category_id=' $category->virtuemart_category_id );

// Show Category ?>

<div class="category floatleft<?php echo $category_cellwidth $show_vertical_separator ?>">
<div class="spacer">
<h2>
<a href="<?php echo $caturl ?>" title="<?php echo $category->category_name ?>">
<?php echo $category->category_name ?>
<br />
<?php // if ($category->ids) {
echo $category->images[0]->displayMediaThumb("",false);
//} ?>

</a>
</h2>
</div>
</div>
<?php
$iCategory ++;

// Do we need to close the current row now?
if ($iCol == $categories_per_row) { ?>

<div class="clear"></div>
</div>
<?php
$iCol 1;
} else {
$iCol ++;
}
}
}
// Do we need a final closing row tag?
if ($iCol != 1) { ?>

<div class="clear"></div>
</div>
<?php ?>
</div>

<?php }
}
?>

<div class="browse-view">
    <?php
if (!empty($this->keyword)) {
?>

<h3><?php echo $this->keyword?></h3>
<?php
?>

<?php if ($this->search !==null ) { ?>
    <form action="<?php echo JRoute::_('index.php?option=com_virtuemart&view=category&limitstart=0&virtuemart_category_id='.$this->category->virtuemart_category_id ); ?>" method="get">

    <!--BEGIN Search Box --><div class="virtuemart_search">
    <?php echo $this->searchcustom ?>
    <br />
    <?php echo $this->searchcustomvalues ?>
    <input name="keyword" class="inputbox" type="text" size="20" value="<?php echo $this->keyword ?>" />
    <input type="submit" value="<?php echo JText::_('COM_VIRTUEMART_SEARCH'?>" class="button" onclick="this.form.keyword.focus();"/>
    </div>
    <input type="hidden" name="search" value="true" />
    <input type="hidden" name="view" value="category" />

    </form>
<!-- End Search Box -->
<?php ?>

<?php // Show child categories
if (!empty($this->products)) {
?>

<div class="orderby-displaynumber">
<div class="width70 floatleft">
<?php echo $this->orderByList['orderby']; ?>
</div>
<div class="width30 floatright display-number"><?php echo $this->vmPagination->getResultsCounter();?><br/><?php echo $this->vmPagination->getLimitBox(); ?></div>
<div class="vm-pagination">
<?php echo $this->vmPagination->getPagesLinks(); ?>
<span style="float:right"><?php echo $this->vmPagination->getPagesCounter(); ?></span>
</div>

<div class="clear"></div>
</div> <!-- end of orderby-displaynumber -->

<h4><?php echo $this->category->category_name?></h4>

<?php
// Category and Columns Counter
$iBrowseCol 1;
$iBrowseProduct 1;

// Calculating Products Per Row
$BrowseProducts_per_row $this->perRow;
$Browsecellwidth ' width'.floor 100 $BrowseProducts_per_row );

// Separator
$verticalseparator " vertical-separator";

// Count products
$BrowseTotalProducts 0;
foreach ( 
$this->products as $product ) {
   
$BrowseTotalProducts ++;
}
?>


<table style="font-size: 12.5px; width: 100%;" class="orders">
<tr style="border: 1px solid #ffb3b3;">
<th style="text-align:center;border: 1px solid #ffb3b3;">Local ICOS</th>
<th style="text-align:center;border: 1px solid #ffb3b3;">Description</th>
<th style="text-align:center;border: 1px solid #ffb3b3;">Expiry Date</th>
<th style="text-align:center;border: 1px solid #ffb3b3;">Batch ID</th>
<th style="text-align:center;border: 1px solid #ffb3b3;">Multipack</th>
<?php jimport'joomla.user.helper' );
      
$user JFactory::getUser();
      
$groups $user->get('groups');
     if(
in_array(15$groups)) { ?>

  <th style="text-align:center;border: 1px solid #ffb3b3;">Jeddah Balance</th><?php ?>
<?php jimport'joomla.user.helper' );
      
$user JFactory::getUser();
      
$groups $user->get('groups');
     if(
in_array(16$groups)) { ?>

  <th style="text-align:center;border: 1px solid #ffcccc;">Riyadh Balance</th><?php ?>
<?php jimport'joomla.user.helper' );
      
$user JFactory::getUser();
      
$groups $user->get('groups');
     if(
in_array(17$groups)) { ?>

  <th style="text-align:center;border: 1px solid #ffb3b3;">Dhahran Balance</th><?php ?>
<?php jimport'joomla.user.helper' );
      
$user JFactory::getUser();
      
$groups $user->get('groups');
     if(
in_array(18$groups)) { ?>

  <th style="text-align:center;border: 1px solid #ffb3b3;">Salaam Mall Balance</th><?php ?>
<th style="text-align:center;border: 1px solid #ffb3b3;">In Stock</th>
<th style="text-align:center;border: 1px solid #ffb3b3;">Cart</th>
</tr>

<?php
// Start the Output
foreach ( $this->products as $product ) {

// Show the horizontal seperator
if ($iBrowseCol == && $iBrowseProduct $BrowseProducts_per_row) { ?>

<div class="horizontal-separator"></div>
<?php }
?>


<tr style="border-bottom: 1px solid #ffb3b3; height: 30px;">
<td style="padding-right: 15px;"><?php 
// Get a db connection.
$db JFactory::getDbo();

// Create a new query object.
$query $db->getQuery(true);

// Select all records from the user profile table where key begins with "custom.".
// Order it by the ordering field.

$query->select($db->quoteName(array('customfield_value''virtuemart_product_id')));
$query->from($db->quoteName('jos_virtuemart_product_customfields'));
$query->where($db->quoteName('virtuemart_custom_id') . ' LIKE '$db->quote('6'). ' AND '$db->quoteName('virtuemart_product_id') . 'LIKE ' $db->quote($product->virtuemart_product_id));

// Reset the query using our newly populated query object.
$db->setQuery($query);

// Load the results as a list of stdClass objects (see later for more options on retrieving data).
$results $db->loadResult();
echo (
$results); 
?>

</td>

<td style="padding-left: 10px;width: 300px; color: #ff3333;">
<?php  echo $product->product_name?>
</td>

<td style="width: 90px; text-align: center;">
<?php 
//MY EDIT STARTS HERE
 //make a database connection and find the field record that contains the customfield string
     
$db JFactory::getDBO();
     
//please do check in php myadmin how your database table is called and replace it instead of "VM2_virtuemart_product_customfields"
     
$db->setQuery("SELECT customfield_value FROM jos_virtuemart_product_customfields WHERE virtuemart_product_id=".$product->virtuemart_product_id.";");
     
$db->query();
     
$result $db->loadResult();
 echo ($result);
//$result is the custom field output
// if you just need the custom field, you're done. I'll show how I did it to change the custom field to what I have
?>

</td>

<td style="width: 120px;text-align: center;">
<?php 
// Get a db connection.
$db JFactory::getDbo();

// Create a new query object.
$query $db->getQuery(true);

// Select all records from the user profile table where key begins with "custom.".
// Order it by the ordering field.

$query->select($db->quoteName(array('customfield_value''virtuemart_product_id')));
$query->from($db->quoteName('jos_virtuemart_product_customfields'));
$query->where($db->quoteName('virtuemart_custom_id') . ' LIKE '$db->quote('4'). ' AND '$db->quoteName('virtuemart_product_id') . 'LIKE ' $db->quote($product->virtuemart_product_id));

// Reset the query using our newly populated query object.
$db->setQuery($query);

// Load the results as a list of stdClass objects (see later for more options on retrieving data).
$results $db->loadResult();
echo (
$results); 
 
?>

</td>

<?php ?>
<?php jimport'joomla.user.helper' );
      
$user JFactory::getUser();
      
$groups $user->get('groups');
     if(
in_array(17$groups)) { ?>


</td> <?php ?>
<td style="text-align:center;">
<?php echo ""$product->product_in_stock ?>
</td>

<td>

<form method="post" class="product" action="index.php" id="addtocartproduct<?php echo $product->virtuemart_product_id ?>">


<div style="margin-top: 25px;" class="addtocart-bar">

   
<span class="quantity-box">
<input type="text" class="quantity-input" name="quantity[]" value="1" />
</span>
<!-- <span class="quantity-controls">
<input type="button" class="quantity-controls quantity-plus" />
<input type="button" class="quantity-controls quantity-minus" />
</span> -->

<?php // Display the quantity box END ?>

<?php // Add the button
$button_lbl JText::_('COM_VIRTUEMART_CART_ADD_TO');
$button_cls ''//$button_cls = 'addtocart_button';
if (VmConfig::get('check_stock') == '1' && !$this->product->product_in_stock) {
$button_lbl JText::_('COM_VIRTUEMART_CART_NOTIFY');
$button_cls 'notify-button';
?>


<?php // Display the add to cart button ?>
<span class="addtocart-button">
<input type="submit" name="addtocart"  class="addtocart-button" value="<?php echo $button_lbl ?>" title="<?php echo $button_lbl ?>" />
</span>

<div class="clear"></div>
</div>

<?php // Display the add to cart button END ?>
<input type="hidden" class="pname" value="<?php echo $product->product_name ?>">
<input type="hidden" name="option" value="com_virtuemart" />
<input type="hidden" name="view" value="cart" />
<noscript><input type="hidden" name="task" value="add" /></noscript>
<input type="hidden" name="virtuemart_product_id[]" value="<?php echo $product->virtuemart_product_id ?>" />
<?php /** @todo Handle the manufacturer view */ ?>
<input type="hidden" name="virtuemart_manufacturer_id" value="<?php echo $product->virtuemart_manufacturer_id ?>" />
<input type="hidden" name="virtuemart_category_id[]" value="<?php echo $product->virtuemart_category_id ?>" />
</form>
</td>


</tr>
<?php }
// end of foreach ( $this->products as $product )
?>





</table></div><!-- end browse-view -->


Now, I installed a fresh VM on another site on my localhost and the quantity box is working. You can enter a number and it calculates it automatically. I did not use an override for this one. Here is the "default.php" code for the category layout in "mysite/components\com_virtuemart\views\category\tmpl". I haven't edited it.


<?php
/**
 *
 * Show the products in a category
 *
 * @package    VirtueMart
 * @subpackage
 * @author RolandD
 * @author Max Milbers
 * @todo add pagination
 * @link https://virtuemart.net
 * @copyright Copyright (c) 2004 - 2010 VirtueMart Team. All rights reserved.
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
 * VirtueMart is free software. This version may have been modified pursuant
 * to the GNU General Public License, and as distributed it includes or
 * is derivative of works licensed under the GNU General Public License or
 * other free or open source software licenses.
 * @version $Id: default.php 9605 2017-07-26 06:22:08Z Milbo $
 */

defined ('_JEXEC') or die('Restricted access');

if (
vRequest::getInt('dynamic',false) and vRequest::getInt('virtuemart_product_id',false)) {
if (!empty($this->products)) {
if($this->fallback){
$p $this->products;
$this->products = array();
$this->products[0] = $p;
vmdebug('Refallback');
}

echo shopFunctionsF::renderVmSubLayout($this->productsLayout,array('products'=>$this->products,'currency'=>$this->currency,'products_per_row'=>$this->perRow,'showRating'=>$this->showRating));

}

return ;
}
?>
<div class="category-view"> <?php
$js 
"
jQuery(document).ready(function () {
jQuery('.orderlistcontainer').hover(
function() { jQuery(this).find('.orderlist').stop().show()},
function() { jQuery(this).find('.orderlist').stop().hide()}
)
});
"
;
vmJsApi::addJScript('vm.hover',$js);

if (
$this->show_store_desc and !empty($this->vendor->vendor_store_desc)) { ?>

<div class="vendor-store-desc">
<?php echo $this->vendor->vendor_store_desc?>
</div>
<?php }

if (!empty(
$this->showcategory_desc) and empty($this->keyword) and !empty($this->category)) {
?>

<div class="category_description">
<?php echo $this->category->category_description?>
</div>
<?php
}

// Show child categories
if ($this->showcategory and empty($this->keyword)) {
if (!empty($this->category->haschildren)) {
echo ShopFunctionsF::renderVmSubLayout('categories',array('categories'=>$this->category->children'categories_per_row'=>$this->categories_per_row));
}
}

if (!empty(
$this->products)) {
?>


<div class="browse-view">
<?php
if ($this->showsearch or $this->keyword !== false) {
//id taken in the view.html.php could be modified
$category_id  vRequest::getInt ('virtuemart_category_id'0); ?>


<!--BEGIN Search Box -->
<div class="virtuemart_search">
<form action="<?php echo JRoute::('index.php?option=com_virtuemart&view=category&limitstart=0'FALSE); ?>" method="get">
<?php if(!empty($this->searchCustomList)) { ?>
<div class="vm-search-custom-list">
<?php echo $this->searchCustomList ?>
</div>
<?php ?>

<?php if(!empty($this->searchCustomValues)) { ?>
<div class="vm-search-custom-values">
<?php echo $this->searchCustomValues ?>
</div>
<?php ?>
<div class="vm-search-custom-search-input">
<input name="keyword" class="inputbox" type="text" size="40" value="<?php echo $this->keyword ?>"/>
<input type="submit" value="<?php echo vmText::('COM_VIRTUEMART_SEARCH'?>" class="button" onclick="this.form.keyword.focus();"/>
<?php //echo VmHtml::checkbox ('searchAllCats', (int)$this->searchAllCats, 1, 0, 'class="changeSendForm"'); ?>
<span class="vm-search-descr"> <?php echo vmText::_('COM_VM_SEARCH_DESC'?></span>
</div>

<!-- input type="hidden" name="showsearch" value="true"/ -->
<input type="hidden" name="view" value="category"/>
<input type="hidden" name="option" value="com_virtuemart"/>
<input type="hidden" name="virtuemart_category_id" value="<?php echo $category_id?>"/>
<input type="hidden" name="Itemid" value="<?php echo $this->Itemid?>"/>
</form>
</div>
<!-- End Search Box -->
<?php
/*if($this->keyword !== false){
?>
<h3><?php echo vmText::sprintf('COM_VM_SEARCH_KEYWORD_FOR'$this->keyword); ?></h3><?php
}*/
$j 'jQuery(document).ready(function() {

jQuery(".changeSendForm")
.off("change",Virtuemart.sendCurrForm)
    .on("change",Virtuemart.sendCurrForm);
})'
;

vmJsApi::addJScript('sendFormChange',$j);
?>


<?php // Show child categories

if(!empty($this->orderByList)) { ?>

<div class="orderby-displaynumber">
<div class="floatleft vm-order-list">
<?php echo $this->orderByList['orderby']; ?>
<?php echo $this->orderByList['manufacturer']; ?>
</div>
<div class="vm-pagination vm-pagination-top">
<?php echo $this->vmPagination->getPagesLinks (); ?>
<span class="vm-page-counter"><?php echo $this->vmPagination->getPagesCounter (); ?></span>
</div>
<div class="floatright display-number"><?php echo $this->vmPagination->getResultsCounter ();?><br/><?php echo $this->vmPagination->getLimitBox ($this->category->limit_list_step); ?></div>

<div class="clear"></div>
</div> <!-- end of orderby-displaynumber -->
<?php ?>

<h1><?php echo vmText::_($this->category->category_name); ?></h1>

<?php
if (!empty(
$this->products)) {
//revert of the fallback in the view.html.php, will be removed vm3.2
if($this->fallback){
$p $this->products;
$this->products = array();
$this->products[0] = $p;
vmdebug('Refallback');
}

echo shopFunctionsF::renderVmSubLayout($this->productsLayout,array('products'=>$this->products,'currency'=>$this->currency,'products_per_row'=>$this->perRow,'showRating'=>$this->showRating));

if(!empty($this->orderByList)) { ?>

<div class="vm-pagination vm-pagination-bottom"><?php echo $this->vmPagination->getPagesLinks (); ?><span class="vm-page-counter"><?php echo $this->vmPagination->getPagesCounter (); ?></span></div>
<?php }
} elseif (
$this->keyword !== false) {
echo vmText::('COM_VIRTUEMART_NO_RESULT') . ($this->keyword ' : (' $this->keyword ')' '');
}
?>

</div>

<?php ?>
</div>

<?php
if(VmConfig::get ('ajax_category'false)){
$j "Virtuemart.container = jQuery('.category-view');
Virtuemart.containerSelector = '.category-view';"
;

vmJsApi::addJScript('ajax_category',$j);
vmJsApi::jDynUpdate();
}
?>

<!-- end browse-view -->


What could be wrong with my custom piece of code?

PS: I had to remove a lot of "<td>'s" in my custom code within the table as it was too many lines.