Forums / Setting Up Categories, Products, Attributes / Creating an add-on "product type book" for ZC 1.5

Creating an add-on "product type book" for ZC 1.5

Views: 111,146

Results 241 to 260 of 427
24 Nov 2014, 10:30 AM
#241
mesnitu avatar

mesnitu

Totally Zenned

Join Date:
Aug 2014
Location:
Lisbon
Posts:
597
Plugin Contributions:
0

Creating an add-on "product type book" for ZC 1.5

Hi
I've send you a testing link.

But , If I turn this featured off, it works nice in a zc behaviour .... so, it's listed as a new product, the button isn't replaced.

When On , button is replaced and nothing is added to the shopping cart.....

Thanks

“Though the problems of the world are increasingly complex, the solutions remain embarrassingly simple.” ― Bill Mollison

24 Nov 2014, 10:46 AM
#242
philou avatar

philou

Zen Follower

Join Date:
Jan 2006
Posts:
165
Plugin Contributions:
1

Re: Creating an add-on "product type book" for ZC 1.5

Okay, i have seen it in your shop, you can delete the test product.
I will make a note and fix it in next release.
p.

24 Nov 2014, 10:51 AM
#243
mesnitu avatar

mesnitu

Totally Zenned

Join Date:
Aug 2014
Location:
Lisbon
Posts:
597
Plugin Contributions:
0

Re: Creating an add-on "product type book" for ZC 1.5

hum... I just remember that this template as some issues with bookx new products.... could that be the case ?
In fact I disable the tabs for the new modules in the front page.... but the sideboxes for new products are working, the new products page is working.... but possible in this featured is one of the cases that doesn't work ?...

if you can't reproduce, that it's this template anda not a issue.

Thanks

“Though the problems of the world are increasingly complex, the solutions remain embarrassingly simple.” ― Bill Mollison

24 Nov 2014, 10:59 AM
#244
philou avatar

philou

Zen Follower

Join Date:
Jan 2006
Posts:
165
Plugin Contributions:
1

Re: Creating an add-on "product type book" for ZC 1.5

Indeed, here it works as expected.
I have seen that on your test page the SUBMIT form is missing two hidden INPUT fields in the HTML.

Your HTML:

<!--bof Add to Cart Box -->
<div id="cartAdd">
	<input class="cssButton button_bookx_new" onmouseover="this.className='cssButtonHover button_bookx_new button_bookx_newHover'" onmouseout="this.className='cssButton button_bookx_new'" type="submit" value="Novo" style="width: 80px;" />
</div>
<!--eof Add to Cart Box-->

HTML I have here:

<!-- bof Add to Cart Box -->

<div id="cartAdd">
    <input type="hidden" value="1" name="cart_quantity"></input>
    <input type="hidden" value="469" name="products_id"></input>
    <input class="cssButton submit_button button button_bookx_new" type="submit" value="Neu! Bestellen" onmouseout="this.className='cssButton submit_button button button_bookx_new'" onmouseover="this.className='cssButtonHover button_bookx_new button_bookx_newHover'"></input>
</div>
<!-- eof Add to Cart Box -->

Below is the part where file tpl_product_bookx_info_display.php is creating the form (around line 532 here), so I can't see at the moment, how your template cannot have the INPUT "quantity" and "product_id" since the template always outputs that… ?

if ($products_qty_box_status == 0 or $products_quantity_order_max== 1) {
					// hide the quantity box and default to 1
					$hidden_quantity = '<input type="hidden" name="cart_quantity" value="1" />' . zen_draw_hidden_field('products_id', (int)$_GET['products_id']);
					$the_button = zen_image_submit(BUTTON_IMAGE_IN_CART, BUTTON_IN_CART_ALT);
			    } else {
			        // show the quantity box
			        $the_button = PRODUCTS_ORDER_QTY_TEXT . '<input type="text" name="cart_quantity" value="' . (zen_get_buy_now_qty($_GET['products_id'])) . '" maxlength="6" size="4" /><br />' . zen_get_products_quantity_min_units_display((int)$_GET['products_id']) . '<br />' . zen_draw_hidden_field('products_id', (int)$_GET['products_id']) . zen_image_submit(BUTTON_IMAGE_IN_CART, BUTTON_IN_CART_ALT);
			    }
24 Nov 2014, 11:23 AM
#245
mesnitu avatar

mesnitu

Totally Zenned

Join Date:
Aug 2014
Location:
Lisbon
Posts:
597
Plugin Contributions:
0

Re: Creating an add-on "product type book" for ZC 1.5

Hi
I made some diff to the original files, but or I'm missing something, but everything is looks equal....

<!--bof Add to Cart Box -->
			<?php
			if (CUSTOMERS_APPROVAL == 3 and TEXT_LOGIN_FOR_PRICE_BUTTON_REPLACE_SHOWROOM == '') {
			  // do nothing
			} else {

				$display_qty = (($flag_show_product_info_in_cart_qty == 1 and $_SESSION['cart']->in_cart($_GET['products_id'])) ? '<p>' . PRODUCTS_ORDER_QTY_TEXT_IN_CART . $_SESSION['cart']->get_quantity($_GET['products_id']) . '</p>' : '');
				$hidden_quantity = '';
				if ($products_qty_box_status == 0 or $products_quantity_order_max== 1) {
					// hide the quantity box and default to 1
					$hidden_quantity = '<input type="hidden" name="cart_quantity" value="1" />' . zen_draw_hidden_field('products_id', (int)$_GET['products_id']);
					$the_button = zen_image_submit(BUTTON_IMAGE_IN_CART, BUTTON_IN_CART_ALT);
			    } else {
			        // show the quantity box
			        $the_button = PRODUCTS_ORDER_QTY_TEXT . '<input type="text" name="cart_quantity" value="' . (zen_get_buy_now_qty($_GET['products_id'])) . '" maxlength="6" size="4" /><br />' . zen_get_products_quantity_min_units_display((int)$_GET['products_id']) . '<br />' . zen_draw_hidden_field('products_id', (int)$_GET['products_id']) . zen_image_submit(BUTTON_IMAGE_IN_CART, BUTTON_IN_CART_ALT);
			    }
			    $display_button = bookx_get_buy_now_button($_GET['products_id'], $the_button);
			  ?>
			  <?php if ($display_qty != '' or $display_button != '') { ?>
			    <div id="cartAdd">
			    <?php
			      echo $display_qty . $hidden_quantity;
			      echo $display_button;
			            ?>
			          </div>
			  <?php } // display qty and button ?>
			<?php } // CUSTOMERS_APPROVAL == 3 ?>
			<!--eof Add to Cart Box-->

“Though the problems of the world are increasingly complex, the solutions remain embarrassingly simple.” ― Bill Mollison

24 Nov 2014, 11:28 AM
#246
philou avatar

philou

Zen Follower

Join Date:
Jan 2006
Posts:
165
Plugin Contributions:
1

Re: Creating an add-on "product type book" for ZC 1.5

Not sure how that is possibly, are you sure this is the file being used? do you have an override file somewhere?
In the above code this HTML "<input type="hidden" name="cart_quantity" value="1" />'" must be in your source code HTML, but it is not there…
do you agree?
p.

24 Nov 2014, 11:30 AM
#247
mesnitu avatar

mesnitu

Totally Zenned

Join Date:
Aug 2014
Location:
Lisbon
Posts:
597
Plugin Contributions:
0

Re: Creating an add-on "product type book" for ZC 1.5

Could this rely on some specific zencart configuration that I don't have ?

“Though the problems of the world are increasingly complex, the solutions remain embarrassingly simple.” ― Bill Mollison

24 Nov 2014, 11:51 AM
#248
philou avatar

philou

Zen Follower

Join Date:
Jan 2006
Posts:
165
Plugin Contributions:
1

Re: Creating an add-on "product type book" for ZC 1.5

Hm, very mysterious.
Try to set the "SHOW CART QUANTITY BOX" to "0" in Admin, maybe that helps?

p.

24 Nov 2014, 12:07 PM
#249
mesnitu avatar

mesnitu

Totally Zenned

Join Date:
Aug 2014
Location:
Lisbon
Posts:
597
Plugin Contributions:
0

Re: Creating an add-on "product type book" for ZC 1.5

Hi
I was checking things, and it's reading the file, and turn on the featured and from the same file the output is different....
Well, you wanted a hidden input right ?There it is ! :D

Anyway, from a "not new" bookx date

<div id="cartAdd">
			    
			    <div><!-- I'm suppose to be here --></div>Adicionar ao Carrinho: <div>----------</div><input type="text" name="cart_quantity" value="1" maxlength="6" size="4"><br><br><input type="hidden" name="products_id" value="1291"><input class="cssButton button_in_cart" onmouseover="this.className='cssButtonHover button_in_cart button_in_cartHover'" onmouseout="this.className='cssButton button_in_cart'" type="submit" value="Adicionar" style="width: 80px;">			          </div>

A new one :

<div id="cartAdd">
			    
			    <div><!-- I'm suppose to be here --></div><input class="cssButton button_bookx_new" onmouseover="this.className='cssButtonHover button_bookx_new button_bookx_newHover'" onmouseout="this.className='cssButton button_bookx_new'" type="submit" value="Novo" style="width: 80px;">			          </div>

I'll try now your suggestion.

Thanks

“Though the problems of the world are increasingly complex, the solutions remain embarrassingly simple.” ― Bill Mollison

24 Nov 2014, 12:24 PM
#250
mesnitu avatar

mesnitu

Totally Zenned

Join Date:
Aug 2014
Location:
Lisbon
Posts:
597
Plugin Contributions:
0

Re: Creating an add-on "product type book" for ZC 1.5

philou:

Hm, very mysterious.
Try to set the "SHOW CART QUANTITY BOX" to "0" in Admin, maybe that helps?

p.

Hi
Nop... I actually had that config... I've turned to 1 , but same results....
I'll have to figured this out later.

ok
Thanks

“Though the problems of the world are increasingly complex, the solutions remain embarrassingly simple.” ― Bill Mollison

27 Nov 2014, 1:20 PM
#251
mesnitu avatar

mesnitu

Totally Zenned

Join Date:
Aug 2014
Location:
Lisbon
Posts:
597
Plugin Contributions:
0

Re: Creating an add-on "product type book" for ZC 1.5

Hi there
I'm having some troubles inserting a product, and I'm not sure why.
Sometimes I can insert the product on the second try, sometimes it just wont insert the product....
I'm getting this error logs :

[27-Nov-2014 13:06:06 Europe/Lisbon] PHP Warning:  Invalid argument supplied for foreach() in /*******/admin/includes/modules/product_bookx/collect_info.php on line 786
[27-Nov-2014 13:06:06 Europe/Lisbon] PHP Warning:  Invalid argument supplied for foreach() in /******/admin/includes/modules/product_bookx/collect_info.php on line 952

The line are:

foreach ($product_assigned_authors as $product_assigned_author) {
						  echo '<div class="drop_down_div">';
						  echo zen_draw_hidden_field('assigned_author_db_id[' . $author_counter . ']', $product_assigned_author['primary_id']);
						  echo TEXT_PRODUCTS_BOOKX_AUTHOR . ' ' . zen_draw_pull_down_menu('bookx_author_id[' . $author_counter . ']', $authors_array, $product_assigned_author['bookx_author_id']);
						  if (1 < count($author_types_array)) {
							  echo TEXT_PRODUCTS_BOOKX_AUTHOR_TYPE . ' ' . zen_draw_pull_down_menu('bookx_author_type_id[' . $author_counter . ']', $author_types_array, $product_assigned_author['bookx_author_type_id']);
						  };
						  echo '</div>';
						  $author_counter++;
					    }

in netbeans there is a warning about a empty statement... but I already worked with no issues inserting other books....

line 952 no warnings....

foreach ($product_assigned_genres as $product_assigned_genre) {
						  echo '<div class="drop_down_div">';
						  echo zen_draw_hidden_field('assigned_genre_db_id[' . $genre_counter . ']', $product_assigned_genre['primary_id']);
						  echo zen_draw_pull_down_menu('bookx_genre_id[' . $genre_counter . ']', $genre_array, $product_assigned_genre['bookx_genre_id']);
						  echo '</div>';
						  $genre_counter++;
					    }

Could this some sort of ID's issue ?

Thanks

“Though the problems of the world are increasingly complex, the solutions remain embarrassingly simple.” ― Bill Mollison

27 Nov 2014, 2:41 PM
#252
mesnitu avatar

mesnitu

Totally Zenned

Join Date:
Aug 2014
Location:
Lisbon
Posts:
597
Plugin Contributions:
0

Re: Creating an add-on "product type book" for ZC 1.5

Hi
I was checking, and just found out that it's because of the meta tags files....
So just placing the files in modules/product_bookx , it's not going to work...

The strange thing, it's sometimes works.....

Placing the files there as another behavior, because of that read directory line, that places the meta tag preview into the product preview.
Also, updating existing metatags, returns always empty tags.... so there was a problem, but I was able to insert the books and after inserting meta_tags, I knew that if I don't edit them, I would be fine.
But not anymore.

Ok, I know you haven't implemented the metags, but just reporting this

Thanks

“Though the problems of the world are increasingly complex, the solutions remain embarrassingly simple.” ― Bill Mollison

27 Nov 2014, 3:42 PM
#253
philou avatar

philou

Zen Follower

Join Date:
Jan 2006
Posts:
165
Plugin Contributions:
1

Re: Creating an add-on "product type book" for ZC 1.5

Hi mesnitu,

from just checking it quickly, I would think that inserting the following lines in product_boox/collect_info.php at line 100 should work:

$product_assigned_authors = array();
$product_assigned_genres = array();

so it reads:

$product_assigned_authors = array();
$product_assigned_genres = array();


if ($pID && empty($_POST)) {

Not sure why meta tags create this problem, but it seems that a special situation arises which means the follwing IF statement is skipped and the two arrays are not defined.

Let me know ho you get on with this.

Regards,
p.

27 Nov 2014, 3:56 PM
#254
mesnitu avatar

mesnitu

Totally Zenned

Join Date:
Aug 2014
Location:
Lisbon
Posts:
597
Plugin Contributions:
0

Re: Creating an add-on "product type book" for ZC 1.5

Hi
As usual it's looking fine now. No error logs, and now it's also possible to update existing meta_tags. :)

Thanks !

“Though the problems of the world are increasingly complex, the solutions remain embarrassingly simple.” ― Bill Mollison

1 Dec 2014, 3:48 PM
#255
chabbu avatar

chabbu

New Zenner

Join Date:
Jul 2007
Posts:
75
Plugin Contributions:
0

Re: Creating an add-on "product type book" for ZC 1.5

Hi
I've installed ZC 1.5.3 with edit orders, super orders and this mod. However, when I add a product to the shopping cart I get a warning msg, digging into the log files, it points to the
includes/classes/shopping_cart.php file, specifically
Unknown column 'pd.products_merkmale' in 'field list'

Does anybody know what may be causing this?

Thanks

4 Feb 2015, 6:23 PM
#256
philou avatar

philou

Zen Follower

Join Date:
Jan 2006
Posts:
165
Plugin Contributions:
1

Re: Creating an add-on "product type book" for ZC 1.5

Hi Chabbu,

please excuse, i did not get notified of your post here for some reason. I have taken the original Shopping cart class file from the german distribution of ZC, so possilby they have made a modification there? If you compare the problematic file in the BookX distribution with the original file in your distribution, then you could check if this is not in your original ZC distribution. In that case I would think you can safely remove the 'pd.products_merkmale'. (Make sure you also check closely if there is an extra colon ',' which you need to remove.

Regards,
p.

18 Jun 2015, 11:14 PM
#257
imagineeratheart avatar

imagineeratheart

New Zenner

Join Date:
Aug 2013
Location:
Redlands, Ca
Posts:
11
Plugin Contributions:
0

Re: Creating an add-on "product type book" for ZC 1.5

Has anyone gotten this to work? I tried downloading it and installing it which was not really an issue there. but I noticed there is no SQL file to add to the database and it doesn't show up in my admin area when trying to add a new book product.

19 Jun 2015, 6:49 AM
#258
philou avatar

philou

Zen Follower

Join Date:
Jan 2006
Posts:
165
Plugin Contributions:
1

Re: Creating an add-on "product type book" for ZC 1.5

Hi Imagine,

once you placed all PHP files where they need to be, you still have to run the installation script in the ZC Admin backend. This will install the necessary database tables. The installation instructions are ncluded in the distribution, did you find them?

Regards,
p

19 Jun 2015, 1:28 PM
#259
dw08gm avatar

dw08gm

Totally Zenned

Join Date:
Sep 2008
Location:
DownUnder, overlooking South Pole.
Posts:
1,018
Plugin Contributions:
2

Re: Creating an add-on "product type book" for ZC 1.5

Hi Philou

A question that has been on my mind for a while is why so many db tables need to be created for this mod.

Surely by consolidating the tables, a significant reduction in the number of sql queries and amount of code would result.

My 2c.

ps ATM I have no need to use this mod, but there may come a day...

22 Jun 2015, 11:27 AM
#260
philou avatar

philou

Zen Follower

Join Date:
Jan 2006
Posts:
165
Plugin Contributions:
1

Re: Creating an add-on "product type book" for ZC 1.5

Hi DW,

it seemed to me the best way to do it.
The idea is to create additional logical entities like author, series, book condition, so that the shop can filter for these. If we roll all of that into one DB table, then we could just use one of the existing modules which add extra fields to a product and then you can store your authors, series, book conditions in there. But then filtering would be quite an act.
One further requirement was that users can choose their own options, like names of series, or type of book conditions they want to use in their shop setup. Since I am myself not using the mod in English, the mod also needs extra tables for language translations. What do you suggest we eliminate?

I also question whether fewer tables would result in a more efficient code execution. Extra JOINS are currently needed to link up all these tables, but I would have to add JOIN clauses all the same, even if all these extra attributes would be collected in a single table.

One thing that is indeed a bit inefficient in this mod, is that it resends some product listing database queries after I have injected the extra logic for BookX attributes, therefore querying the DB twice. This was the only way I saw how to do it using only the observer functionality of ZC, as there was no hook I could observe for to inject my extra query code. That would be a very useful addition to ZC in my opinion. The other option would be to hack the DB queries in core code, which I did not want to do to remain as forward compatible as possible and I also assumed that most users are not so happy altering ZC core code.

Hope that answers your question ;)
p.