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
-
May 29, 2010 at 8:16 pm #18568darkmatterMember
OK, I’ve been looking a this tediously and from what I can tell:
‘if(!empty($nggImage->alttext))
{
$output .= “<input type=”hidden” name=”item_name” value=”$nggImage->alttext” />”;
}
else
{
$output .= “<input type=”hidden” name=”item_name” value=”$ret_product->name” />”;
}’
This is returning the image alttext on the Paypal page.
Yet when I try to recall same in another function it doesn’t work. What I’d like to do is place somewhere in:
‘if($ret_product->custom_input == ‘1’)
{
if(!empty($ret_product->custom_input_label))
$var_output .= $ret_product->custom_input_label.’: <input type=”text” name=”custom_input” value=”” class=”eStore_text_input” />’;
else
$var_output .= ‘Instructions: <input type=”text” name=”custom_input” value=”” class=”eStore_text_input” />’;
if ($line_break) $var_output .= ‘
‘;else $var_output .= ‘ ‘;
}’
… how to do that??
Thanks
May 30, 2010 at 9:18 am #18569amin007ParticipantYou can’t access the value of $nggImage->alttext unless the function is being called from a nextGen gallery template file and the reference to the image is passed down.
May 30, 2010 at 4:53 pm #18570darkmatterMemberI created a template file and placed it in ngg gallery’s view folder. The template has ‘<?php echo get_button_code_for_product(1); ?>’ where I need the add to cart code. Product 1 is the product I want to use for all pics on this gallery.
The template you created which has ‘<?php echo print_eStore_ngg_buy_now($image); ?>’ is essentially calling the same eStore_misc_functions.php file where both functions are located with the difference being that get_button_code_for_product($id) refers to the variations/etc in eStore_button_display_helper.php. Is that why it’s not working? Do I need to transpose all of the functions onto the same file for everything to work correctly?
Again pardon my ignorance with php, I really hope you can help out!
Vince
May 31, 2010 at 2:42 am #18571amin007ParticipantYou can modify the “get_button_code_for_product” function in the eStore_misc_functions.php file so it takes another argument (the image reference).
so the function definition will look like the follwoing:
function get_button_code_for_product($id, $image='')
Now, when you call this function from the template file you can pass the image reference like the following:
<?php echo get_button_code_for_product(1,$nggImage); ?>
This will allow you to get the alt text for the image in question by using the following in the “get_button_code_for_product” function:
$nggImage->alttext
May 31, 2010 at 7:17 pm #18572darkmatterMemberThank you!
$image=” or $nggImage=” for the image reference in the function? I’m assuming you meant $nggImage.
Here’s what I did:
– added $nggImage=” as an argument to function get_button_code_for_product
function get_button_code_for_product($id,$nggImage='')
– added $nggImage to the function call in the template file
<?php echo get_button_code_for_product(1,$nggImage); ?>
– added $nggImage to call the image alttext in the button helper
if($ret_product->custom_input == '1')
{
if(!empty($ret_product->custom_input_label))
$var_output .= $ret_product->custom_input_label.': <input type="text" name="custom_input" value="'.$nggImage->alttext.'" class="eStore_text_input" />';
else
$var_output .= 'Instructions: <input type="text" name="custom_input" value="" class="eStore_text_input" />';
if ($line_break) $var_output .= '<br />';
else $var_output .= ' ';
}Unfortunately, nothing shows up in the custom field: http://camelarae.com/galleries/i9-sports-galleries/i9-sports-flag-winter2010/test-gallery-with-purchase
Not sure I’ve got the argument in the right places. Is $nggImage an actual variable that exists in a table from an ngg gallery array? I see $image in ngg’s code… I’m lost
June 1, 2010 at 12:49 am #18573amin007ParticipantWhen you pass a parameter to a function the reference to it becomes the name you specify in the function’s parameter list. So you could be passing the following to a function:
$a = 2;
$b = 3;
sum_two_numbers($a,$b);Now if the function looks like the following then inside this function a and b becomes c and d respectively:
function sum_two_numbers($c,$d)
Anyway, you can use the same name if it makes it easier.
Next, I was only giving you examples in my code. When you are passing the reference from the nextgen gallery template you need to use the variable name as it is used on that file. If you uses $image then you need to pass in $image like the following:
<?php echo get_button_code_for_product(1,$image); ?>
June 1, 2010 at 5:00 pm #18574darkmatterMemberI guess what I don’t quite understand is the hierarchy as it relates to the position of the call to a parameter. In other words, I can have
function get_button_code_for_product($id,$image='')
and<?php echo get_button_code_for_product(1,$image); ?>
but then if I call $image in eStore_button_display_helper.php as above with $nggImage, nothing happens.Do I also need to add the reference in eStore_button_display_helper.php somewhere?
Once again, lost haha!
June 1, 2010 at 6:11 pm #18575darkmatterMemberOK, I figured it out finally…
In eStore_misc_functions.php:
function get_button_code_for_product($id,$image)
and
function get_button_code_for_element($ret_product,$line_break=true,$ngg2Image='')
and
$var_output = get_variation_and_input_code($ret_product,$line_break,$ngg2Image);
In eStore_button_display_helper.php:
function get_variation_and_input_code($ret_product,$line_break=true,$ngg2Image)
and
$var_output .= $ret_product->custom_input_label.': <input type="text" name="custom_input" value="'.$ngg2Image->alttext.'" class="eStore_text_input" />';
I understand all this much better now. Thanks again for your patience in helping me out
July 20, 2010 at 5:38 pm #18576singhiMemberHi Darkmatter,
im working on a site trying to do the exact same thing as you on camelarae.com.
Im am a PHP-Newbie but ive tried to paste the your code into the eStore_misc_functions.php and eStore_button_display_helper.php and getting errors.
It would be great to get a little “How to” from you.
Really appreciate your help.
Singhi
July 20, 2010 at 6:07 pm #18577darkmatterMemberIt’s been a while since I looked at this… there were several steps which affected multiple files including the NGG Gallery view files. Have you made any changes in the NGG/e-Store gallery viewer located in plugins/nextgen-gallery/view ?
July 20, 2010 at 6:57 pm #18578singhiMemberI suppose thats the point. I havent made any changes to my templates in plugins/nextgen-gallery/view. Would you mind to share your files or pluginfolder?
August 7, 2010 at 2:50 pm #18579PokieMemberI too would be interested in your files please.
I have been struggling with this for a week now.
I have been using import and export from SQL to manipulate the data, but you method looks much easier and better.
It would be grealy appreciate if you would provide the files.
Cheers
Pokie
August 9, 2010 at 6:55 pm #18580darkmatterMemberIt’s been a while, but I’ll try to outline the steps. The essence of this (and please keep in mind that I’m not a programmer or proficient at php so I’m going by deduction) is to add a new variable that can be called from the NGG view template with the data you’re looking to carry over. In my case, it’s the customer input field, normally used for customers to give you special instructions, but that I’m using to auto-populate with the name of the photo from the NG Gallery.
1. Place gallery-wp-estore-addtocart.php in your NG Gallery’s plugin ‘view’ folder.
2. Replace eStore_misc_functions.php and eStore_button_display_helper.php in the wp-cart-for-digital-products (WP eStore) plugin folder.
3. Upload all of your pics to NG Gallery (in a new gallery).
4. Create a new product in WP eStore and check the “Collect Customer Input” option. I don’t think you need to enter any text for the label. This just makes it possible to use the field for our purposes. I priced the product (Photo Print) at $0 and then added all of the variations I wanted at their full price (example: PRINTS|4×6:5|5×7:7|Two 5×7:12|8×10:12|11×14:20|12×16:25 etc.)
5. Place shortcode [nggallery id=x template=wp-eStore-addtocart] in your page/post (x is the gallery ID number).
If I’m not mistaken, that’s it.
Don’t forget to set an Add To Cart button link for the WP eStore Settings (Add to Cart button text or Image).
Displaying a gallery with these options should yield something similar to http://camelarae.com/galleries/sloan-canyon-christian-academy as far as functionality goes.
Good luck!
August 10, 2010 at 11:10 pm #18581PokieMemberThanks you so much for taking the time to provide this.
This is the exact solution I was looking for and am surprised it is not built in.
This is perfect for selling hard copy prints of ones pictures.
Thanks again.
Pokie
August 10, 2010 at 11:15 pm #18582darkmatterMemberStrange, I had posted a link to the zip file with the files and now it’s gone?
[admin deleted the link]
===== Updated by admin =====
LOL… I kept a backup and deleted that link. Not a very good idea to have links with sourecode
Nobody will be able to just copy and paste it anyway as those files are constantly changing with newer version of eStore. It’s better to just have your step by step guideline which is very complete for any coder to follow.
-
AuthorPosts
- You must be logged in to reply to this topic.