Clone add to cart

Phoca Cart - complex e-commerce extension
mjmartino
Phoca Enthusiast
Phoca Enthusiast
Posts: 64
Joined: 10 Jun 2019, 15:53

Clone add to cart

Post by mjmartino »

Hi
How to clone button add to cart to deferent place without no quantity. And change only string language.
I create file.
button_add_to_cart_item_custom.php

Code: Select all

<?php
defined('_JEXEC') or die;
use Joomla\CMS\HTML\HTMLHelper;

?>

<div class="<?php echo $d['s']['c']['pull-right'] ?> <?php echo $d['s']['c']['form-group'] ?> ph-item-add-to-cart-box">
	<input type="hidden" name="id" value="<?php echo (int)$d['id']; ?>">
	<input type="hidden" name="catid" value="<?php echo (int)$d['catid']; ?>">
	<input type="hidden" name="task" value="checkout.add">
	<input type="hidden" name="tmpl" value="component" />
	<input type="hidden" name="option" value="com_phocacart" />
	<input type="hidden" name="return" value="<?php echo $d['return']; ?>" />
	<div class="<?php echo $d['s']['c']['form-group'] ?> ph-form-quantity phProductAddToCart<?php echo $d['typeview']. (int)$d['id'] .' '.$d['class_btn']; ?>">
	</div>
	 <div class="<?php echo $d['s']['c']['form-group'] ?> ph-form-button"><?php
	if ($d['addtocart'] == 1) {
		?><button type="submit" class="<?php echo $d['s']['c']['btn.btn-primary'] ?> ph-btn phProductAddToCart<?php echo $d['typeview'] . (int)$d['id'] .' '.$d['class_btn']; ?>"><span class="<?php echo $d['s']['i']['shopping-cart'] ?>"></span> <?php echo JText::_('Kupit'); ?></button><?php
	} else if ($d['addtocart'] == 4) {
		?><button type="submit" class="<?php echo $d['s']['c']['btn.btn-primary'] ?> ph-btn phProductAddToCart<?php echo $d['typeview']. (int)$d['id'] .' '.$d['class_btn']; ?>" title="<?php echo JText::_('Kupit'); ?>"><span class="<?php echo $d['s']['i']['shopping-cart'] ?>"></span></button><?php
	} ?>
	<?php /* <input type="submit" value="submit" name="submit" role="button" /> */ ?>
</div>
	<div class="ph-cb"></div>
<?php echo Joomla\CMS\HTML\HTMLHelper::_('form.token'); ?>
</div>
Change view.
I add to templates/as002027free/html/com_phocacart/item/default.php
281 line.

Code: Select all

echo JLayoutHelper::render('button_add_to_cart_custom', $d, JPATH_SITE.'/templates/as002027free/html/layouts/com_phocacart/');
button dont show.

Event if i add

Code: Select all

echo $layoutA->render($d);
show only quantity but button nope.
Is this some kind of protection against adding a second button?
:idea:
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48386
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Clone add to cart

Post by Jan »

Hi, you need to debug:

1) if this file is really loaded (just add some var_dump or print_r, etc. to the file)

2) if the buttons are displayed and the IF codintions are valid (e.g. $d['addtocart'] variable)

Jan
If you find Phoca extensions useful, please support the project
Post Reply