
For me, as an ASP person, I feel like I am trying to talk in a close language (like French and Italian) where I can understand one word in10

seriously,, I think you are all being very kind. I wish here was something I could do to help back, other than donate.
oh boy... it is a dream I have too... if anyone can come up with a solution for this version of Open Cart.. I would be prepared to pay.
Imagine I got this code:
Code: Select all
<form action="<?php echo $products[$j]['href2']; ?>" method="post" enctype="multipart/form-data" id="category_product_<?php echo $j; ?>">
<input type="hidden" name="quantity" size="3" value="1" />
<input type="hidden" name="product_id" value="<?php echo $products[$j]['product_id']; ?>" />
<div class="itemBuy">
<a onclick="$('#category_product_<?php echo $j; ?>').submit();"><img src="catalog/view/theme/dbstr/stylesheet/images/icons/greenBasket.png" /></a>
</div>
</form>
Request Reviews v1.0 released.
So my new question would be, if anyone got a working solution already, or can help make it? I assume it should be pretty easy, if you know your jQuery.
Request Reviews v1.0 released.

Request Reviews v1.0 released.
Request Reviews v1.0 released.
Go to line 143 and find the product array.
Find: 'model' => $result['model'],
After, insert:
'product_id' => $result['product_id'],
'href2' => $this->url->http('checkout/cart'),
Go to line 229 and find: $this->data['order'] = $order;
Insert after: $this->data['button_add_to_cart'] = $this->language->get('button_add_to_cart');
Open: product/category.tpl (in your template folder)
Add the following code, to the image tag (line 42 in standard template)
Code: Select all
id="image_<?php echo $products[$j]['product_id']; ?>"
Code: Select all
<form action="<?php echo $products[$j]['href2']; ?>" method="post" enctype="multipart/form-data" id="category_product_<?php echo $products[$j]['product_id']; ?>">
<input type="hidden" name="quantity" size="3" value="1" />
<input type="hidden" name="product_id" value="<?php echo $products[$j]['product_id']; ?>" />
<a class="add2cart button" onclick="$('#category_product_<?php echo $products[$j]['product_id']; ?>').submit();" id="category_product_<?php echo $products[$j]['product_id']; ?>"><span><?php echo $button_add_to_cart; ?></span></a>
Also, you might want to split this code up, but it's basic html, so it shouldn't be a problem, if you got this far)
Now to the fun part -> Open module/cart.tpl (in your template folder)
At line 59 and 60 you will find:
Code: Select all
});
});
Code: Select all
$('a.add2cart[class]').each(function() {
var $t = $(this);
$t.removeAttr('onclick')
});
$("a[id^='category_product']").click(function () {
var productIDValSplitter = (this.id).split("_");
var productIDVal = productIDValSplitter[2];
$.ajax({
type: 'post',
url: 'index.php?route=module/cart/callback',
dataType: 'html',
data: $('#category_product_'+ productIDVal +' :input'),
success: function (html) {
$('#module_cart .middle').html(html);
},
complete: function () {
var image = $('#image_' + productIDVal).offset();
var cart = $('#module_cart').offset();
$('#image_' + productIDVal).before('<img src="' + $('#image_' + productIDVal).attr('src') + '" id="temp" style="position: absolute; top: ' + image.top + 'px; left: ' + image.left + 'px;" />');
params = {
top : cart.top + 'px',
left : cart.left + 'px',
opacity : 0.0,
width : $('#module_cart').width(),
heigth : $('#module_cart').height()
};
$('#temp').animate(params, 'slow', false, function () {
$('#temp').remove();
});
}
});
});
* If you are insecure about where to place the above code, and you haven't made any changes to the original jQuery,
you can replace the whole javascript with this:
Code: Select all
<script type="text/javascript"><!--
$(document).ready(function () {
$('#add_to_cart').replaceWith('<a onclick="" id="add_to_cart" class="button">' + $('#add_to_cart').html() + '</a>');
$('#add_to_cart').click(function () {
$.ajax({
type: 'post',
url: 'index.php?route=module/cart/callback',
dataType: 'html',
data: $('#product :input'),
success: function (html) {
$('#module_cart .middle').html(html);
},
complete: function () {
var image = $('#image').offset();
var cart = $('#module_cart').offset();
$('#image').before('<img src="' + $('#image').attr('src') + '" id="temp" style="position: absolute; top: ' + image.top + 'px; left: ' + image.left + 'px;" />');
params = {
top : cart.top + 'px',
left : cart.left + 'px',
opacity : 0.0,
width : $('#module_cart').width(),
heigth : $('#module_cart').height()
};
$('#temp').animate(params, 'slow', false, function () {
$('#temp').remove();
});
}
});
});
$('a.add2cart[class]').each(function() {
var $t = $(this);
$t.removeAttr('onclick')
});
$("a[id^='category_product']").click(function () {
var productIDValSplitter = (this.id).split("_");
var productIDVal = productIDValSplitter[2];
$.ajax({
type: 'post',
url: 'index.php?route=module/cart/callback',
dataType: 'html',
data: $('#category_product_'+ productIDVal +' :input'),
success: function (html) {
$('#module_cart .middle').html(html);
},
complete: function () {
var image = $('#image_' + productIDVal).offset();
var cart = $('#module_cart').offset();
$('#image_' + productIDVal).before('<img src="' + $('#image_' + productIDVal).attr('src') + '" id="temp" style="position: absolute; top: ' + image.top + 'px; left: ' + image.left + 'px;" />');
params = {
top : cart.top + 'px',
left : cart.left + 'px',
opacity : 0.0,
width : $('#module_cart').width(),
heigth : $('#module_cart').height()
};
$('#temp').animate(params, 'slow', false, function () {
$('#temp').remove();
});
}
});
});
});
//--></script>
Request Reviews v1.0 released.
dbstr, just one remark on your great guide in your last post...
</form> is missing!!!!!

I know it's a stupid thing and it is present in previous posts but... I was just following your last instructions and, without </form> closure, things were not obviously well... I was losing my head... then, finally I find out this damned missing part...
many thanks again.
Max
-----------------------------------------------------------------------
My last mods: Partita IVA e CF | Pro EU VAT Number | Sales Agents | Pricelist Pro
-----------------------------------------------------------------------
Also, you would want to change the id's, to get it to w3c validate properly. ;-)
Request Reviews v1.0 released.
I was wondering if you could help me/us again... I would like to insert first lines of product description directly in products list (I already changed the view in order to have only one product for each line, so I have some space to insert description).
What do you think about? Is it something doable easily?
Many thanks in advance, I will be grateful even with some tips.
Max
-----------------------------------------------------------------------
My last mods: Partita IVA e CF | Pro EU VAT Number | Sales Agents | Pricelist Pro
-----------------------------------------------------------------------
Either way, you should open and edit catalog/controller/product/category.php, and find the data array for the product listing.
For, let's say, the first 50 chars, you should just add:
Code: Select all
'description' => substr(strip_tags(html_entity_decode($result['description'])),1,50),
This is just something I found on google, so I'll just give you this, as it's much easier than starting to explain how my own stuff would work!

At the bottom of catalog/controller/product/category.php BEFORE the last } insert this:
Code: Select all
private function shorten_string($string, $wordsreturned)
/* Returns the first $wordsreturned out of $string. If string
contains more words than $wordsreturned, the entire string
is returned.*/
{
$retval = $string; // Just in case of a problem
$array = explode(" ", $string);
/* Already short enough, return the whole thing*/
if (count($array)<=$wordsreturned)
{
$retval = $string;
}
/* Need to chop of some words*/
else
{
array_splice($array, $wordsreturned);
$retval = implode(" ", $array)." ...";
}
return $retval;
}
Code: Select all
'description' => ControllerProductCategory::shorten_string(strip_tags(html_entity_decode($result['description'])),20),
In your view file, simply add
Code: Select all
<?php echo $products[$j]['description']; ?>

Request Reviews v1.0 released.
Users browsing this forum: No registered users and 6 guests