Tips and Tricks HQ Support Portal › Forums › WP eStore Forum › WP eStore F.A.Q/Instructions › Why Configure Every Product Separately When Used with NextGen Gallery
- This topic has 102 replies, 15 voices, and was last updated 11 years, 3 months ago by ssaf.
-
AuthorPosts
-
September 16, 2010 at 8:14 pm #18613ParrisMember
Hi Folks,
Would anyone who has got this modification working be willing to help me get it running? I think I’m probably just missing some small detail somewhere. The testing site for my project is littlegraphicsengine.com/wpcms/main-gallery
As you should see on the page (linked above), I have the name of the file showing to the left of the variations dropdown, the customer field is showing up on the second line (with the default label of “Instructions”), and I have an “Add to Cart” button graphic on the third line. I just don’t have the customer field populated with the file name (which I think is what needs to happen for the file name to get passed to the cart. Right?)
I’m not a PHP coder but I think I’ve been able to follow the basic logic. Here’s what I’ve done following Dark Matter’s instructions and various other member’s snippets in this thread (while I’m at it, I figure I’ll try and include a good level of detail so we’ll have a more complete step by step. So sorry in advance for the long post):
1. Starting in the plugins directory of my WordPress installation, I made a copy of gallery-wp-eStore.php (from wp-cart-for-digital-productsview) , renamed it “gallery-wp-eStore-addtocart.php” and put it in nextgen-galleryview. I then added this code to wp-eStore-addtocart.php just after the closing “/a” html tag in the Thumbnails section:
<span class="prod_detail"><?php echo $image->alttext ?><?php echo get_button_code_for_product(1,$image); ?></span>
2a.In wp-cart-for-digital-products I modified eStore_misc_functions.php, adding the $image variable to the existing function so that it now look like this:
function get_button_code_for_product($id,$image)
{
global $wpdb;
$products_table_name = WP_ESTORE_PRODUCTS_TABLE_NAME;
$ret_product = $wpdb->get_row("SELECT * FROM $products_table_name WHERE id = '$id'", OBJECT);
$output = get_button_code_for_element($ret_product,'',$image);
return $output;
}($image added in two places) and adding $ngg2Image=” to this other function here:
function get_button_code_for_element($ret_product,$line_break=true,$ngg2Image='')
and adding $ngg2Image further down in this same function so it looks like this:
$var_output = get_variation_and_input_code($ret_product,$line_break,$ngg2Image);
2b. Also in wp-cart-for-digital-products I modified eStore_button_display_helper.php, adding the $ngg2Image variable to an existing function so that it now looks like this:
function get_variation_and_input_code($ret_product,$line_break=true,$ngg2Image,$button_type=1)
Then towards the bottom of the function, I added $ngg2Image so that it looks like this:
$var_output .= $ret_product->custom_input_label.': <input type="text" name="custom_input" value="'.$nggImage->alttext.'" class="eStore_text_input" />';
3. I have a gallery of pictures set up using NextGen.
4. I created a new product in eStore with “Collect Customer Input” checked and left the Field Label blank ( in the “Additional Product Details” section), set a Product Price of 0.00 and added my variations.
5. I have the shortcode [nggallery id=1 template=wp-eStore-addtocart] in a page called Landscapes (1 is the gallery ID number for my gallery, also called Landscapes).
6. Following the standard instructions for NextGen gallery and eStore I have these settings as well:
Under Gallery (NextGen settings), in “Manage Gallery”, I have my gallery “Landscapes” with Page Link to “Landscapes” (the page with this name). Also, since I have this gallery in an album and want the album thumbnails to link to the actual page where my “Add to Cart” buttons show up (and not the gallery url that NextGen gallery assigns to Album thumbs by default), I have “Deactivate gallery page link:” unchecked (in Options/Gallery tab).
Then for eStore’s settings I have an Add To Cart button link set (in Settings/General Settings (Add to Cart button text or Image). Also I have “Product ID to be Used as a Template” set to 1 (in WP eStore Settings/3rd Party Integration/NextGen Gallery Settings (1 is the ID of my product that I’m using as a template).
7. Once the file name is showing up in the field properly, then the field needs to be hidden so customers won’t accidentally put something else in there. I think it’s a simple matter of hiding the field with CSS (which I can figure out). But I don’t remember how to do that at the moment, so if anyone wants to chime in about that, please do! Otherwise I’ll add it to this Step by Step later, once I get things working.
Ok, I think that is it, minus whatever crucial bit I’m missing (as it’s not yet working [customer field not getting populated with the file name of the image], which is why I need help).
Thanks!
September 16, 2010 at 8:33 pm #18614darkmatterMember@ Parris
Re: item 2a, $ngg2Image=” gets added here:
function get_button_code_for_element($ret_product,$line_break=true,$ngg2Image=”)
and here
$var_output = get_variation_and_input_code($ret_product,$line_break,$ngg2Image);
$image also exists here:
function print_eStore_ngg_buy_now($image)
{
$output = “”;
$product_id = get_option(‘eStore_ngg_template_product_id’);
if(empty($product_id))
{
$output .= “You need to specify a product ID in the 3rd Party Settings of eStore”;
}
else
{
$output .= print_eStore_buy_now_button($product_id,”,$image);
}
return $output;
}
…but I can’t recall if that was already there in the original file, perhaps. either way it needs to be there.
Re: item 2b, your code is missing the “2” in “$ngg2Image” as such:
‘<input type=”text” name=”custom_input” value=”‘.$ngg2Image->alttext.'” class=”eStore_text_input” />’
Check, correct and test and let me know if that solved it.
Then, to hide the field, in teh eStore css file, I used:
.eStore_text_input {
font-size:1.3em;
height:0px;
width: 0px;
color:#444;
background:#eee;
border:0px solid #aaa;
border-right-color:#ddd;
border-bottom-color:#ddd;
margin:0px auto 0px
}
.eStore_text_input:focus {
height:0px;
background:#fff;
border-color:#777 #ccc #ccc #777;
margin:2px
}
Try that!
Vince aka Darkmatter
September 16, 2010 at 8:36 pm #18615ParrisMemberI just thought I should add that I saw on page 6 and 7 of this thread (dark matter and jonnylaris’s posts) that there was a concern that the version of eStore might be an issue. I think it was decided that it doesn’t matter. However, just in case, my version is 4.2.7
September 16, 2010 at 8:41 pm #18616ParrisMemberdark matter –
Wow. Your response was fast. I can’t believe you read through my long post already and replied noting my error(s). This is Great! I will correct, test, and let you know. Thanks.
September 16, 2010 at 9:28 pm #18617ParrisMember@dark matter
Well I fixed my missing “2” in eStore_button_display_helper.php so that it reads:
$var_output .= $ret_product->custom_input_label.': <input type="text" name="custom_input" value="'.$ngg2Image->alttext.'" class="eStore_text_input" />';
That was the only thing I could find to correct since the $image references you mentioned do exist already in the original code.
I’m afraid I still don’t have anything showing up inside the field. Is that what you see?
September 16, 2010 at 9:34 pm #18618darkmatterMemberIf you want to give me access to your site I can poke around. Yahoo IM metal_dude_man
September 16, 2010 at 9:49 pm #18619ParrisMemberHey, cool. Thanks. I’m installing Yahoo IM now.
September 16, 2010 at 11:13 pm #18620darkmatterMemberOK everyone, a small change to the code in eStore_button_display_helper.php file, be sure to set the default field label code as such:
to $var_output .= ‘Instructions: <input type=”text” name=”custom_input” value=”.$ngg2Image->alttext.” class=”eStore_text_input” />’;
If you don’t, your image name will not carry over without entering a field label for the customer input instructions for the product in question. The value=”” field must be filled with the .$ngg2Image->alttext. variable in both conditions.
Cheers!
September 17, 2010 at 12:22 am #18621ParrisMemberRight. For me, I think this was the last thing keeping the field from being filled with the image file name (because I had “Collect Customer Input” checked correctly(in Manage Products/[whateveryourproductnameis]/Edit/Additional Product Details/), but absolutely nothing in the “Field Label:”. I think this triggers the function that gives you the default label of “Instructions”. Dark Matter knows what’s up. Thank you for finding this glitch that was keeping from success!
September 17, 2010 at 12:38 am #18622ParrisMemberSmall syntax correction: needs to be:
to $var_output .= 'Instructions: <input type="text" name="custom_input" value="'.$ngg2Image->alttext.'" class="eStore_text_input" />';'
(notice the quote symbols on either side of .$ngg2Image->alttext.)September 17, 2010 at 12:39 am #18623darkmatterMemberThanks for that correction!
September 17, 2010 at 12:53 am #18624ParrisMemberAnd I just discovered I still needed to have at least a space <spacebar> in the field label (in Additional Product Details) to keep the word “Instructions” from showing up. Chalk that up to my very dim understanding of how this all works.
September 17, 2010 at 12:58 am #18625darkmatterMemberCorrect. You’d have to go in the code and delete “Instructions:” like this:
to $var_output .= ‘<input type=”text” name=”custom_input” value=”‘.$ngg2Image->alttext.'” class=”eStore_text_input” />’;
September 17, 2010 at 7:20 pm #18626Arrow325MemberI’m trying to make this same modification. I’m on version 4.3.3, so that might be the problem. I went through the steps that Parris outlined, updating eStore_misc_functions.php and eStore_button_display_helper.php, and then I put the shortcode “[nggallery id=1 template=wp-eStore-addtocart]” in my gallery.
But I get this error above the images, repeated twice:
“Warning: Missing argument 2 for get_button_code_for_product(), called in /home/arrow325/public_html/wp-content/plugins/wp-cart-for-digital-products/wp_eStore1.php on line 803 and defined in /home/arrow325/public_html/wp-content/plugins/wp-cart-for-digital-products/eStore_misc_functions.php on line 90”
I checked the referenced code, but I don’t know enough to understand what the problem is. Here is the referenced code (specific lines are bold):
wp_eStore1.php:
function print_wp_digi_cart_button($content)
{
$pattern = ‘#[wp_eStore:product_id:.+:end]#’;
preg_match_all ($pattern, $content, $matches);
foreach ($matches[0] as $match)
{
$pattern = ‘[wp_eStore:product_id:’;
$m = str_replace ($pattern, ”, $match);
$pattern = ‘:end]’;
$m = str_replace ($pattern, ”, $m);
$pieces = explode(‘|’,$m);
$key = $pieces[0];
if (sizeof($pieces) == 1)
{
$replacement = get_button_code_for_product($key);
$content = str_replace ($match, $replacement, $content);
}
}
return $content;
}
eStore_misc_functions.php:
function get_button_code_for_product($id,$image)
{
global $wpdb;
$products_table_name = WP_ESTORE_PRODUCTS_TABLE_NAME;
$ret_product = $wpdb->get_row(“SELECT * FROM $products_table_name WHERE id = ‘$id'”, OBJECT);
$output = get_button_code_for_element($ret_product,”,$image);
return $output;
}
You can see this error in action here: http://thinktankgallery.com/?page_id=68
Any help would be greatly appreciated!
September 17, 2010 at 7:41 pm #18627darkmatterMemberWhat’s line 90 of eStore_misc_functions.php?
Did you create a new NG Gallery view template first with the required code?
Vince
-
AuthorPosts
- You must be logged in to reply to this topic.