Tips and Tricks HQ Support Portal › Forums › WP eStore Forum › WP eStore Troubleshooting › eStore – Need Meta Key of Product ID for Essential Grid
Tagged: custom data, essential grid, shortcode
- This topic has 4 replies, 2 voices, and was last updated 4 years, 6 months ago by stalyan.
-
AuthorPosts
-
May 1, 2020 at 10:10 pm #14518stalyanParticipant
Hi,
When you edit a skin in Essential Grid you can also add meta keys. I’ve been able to include a Add Cart button going to Layout Settings > Source > Blank HTML but as in Essential Grid a skin is a template that applies to all images of let’s say a Playlist, the problem is that I have an Add Cart button of a specific song image by internal ProductID, that same product id will be replicated to all the other song images, when they are actually different products.
So instead of pasting [wp_eStore_fancy1_no_thumbnail id= 1] in the Blank HTML, I would need to paste something like:
[wp_eStore_fancy1_no_thumbnail id= MetaKeyOfProductID]
being MetaKeyOfProductID a numerical value. No problem to create this key pair from another plugin of directly on a post, but I need to know is somehow I can make eStore to recognize that.
(I don’t ask for a feature to be included, just asking if it’s possible or if it’s too complicated i’ll appreciate if you can point me out on the direction to investigate on my own
I don’t know how i can attach images let me know.
Thanks,
Abel
May 1, 2020 at 11:40 pm #80527wzpModerator(I don’t ask for a feature to be included, just asking if it’s possible or if it’s too complicated i’ll appreciate if you can point me out on the direction to investigate on my own
Many of the eStore shortcodes have equivalent PHP function calls. Perhaps you might be able to use them?
May 2, 2020 at 11:03 pm #80528stalyanParticipantThanks for the info.
I managed to complete the first part of the problem, that is getting the productID from post custom data and add it to the eStore PHP code.
<?php
$customMeta = get_post_meta(get_the_ID(), ‘eStoreProductID’, TRUE);
printf( ‘The value of my post meta is %s’, $customMeta );
echo show_product_fancy_style($customMeta);
?>
I used XYZ PHP Code to create a shortcode of this. Then if I put this shortcode called RetrieveCustomMetaToVariable on a post that has custom data ‘eStoreProductID’, which has the same value of the product id in eStore, it will display the correct Add to Cart button and associated info.
Now my problem is how to pass this into the Essential Grid Skin editor (EGSE) so the Add to Cart button is displayed within each song cover in the grid. EGSE has a HTML/Text form but i cannot use it to post XYZ PHP Code shortcodes. Also, I cannot post any eStore HTML shortdcode in the form because the productid of eStore HTML shortcodes must be a fixed number and not a variable. If I paste PHP code directly there it just does not work either.
I found this in Essential Grid customer support: https://www.themepunch.com/faq/create-a-custom-shortcode-in-essential-grid/
It’s my only hope to somehow try to adapt the PHP code that I posted to create a shortcode as specified in the link above, but using the eStoreProductID variable as a function argument that I can use as argument of this newly created shortcode that Essential Grid should recognize.
[AddToCartButton %eStoreProductID%]
I must say i do not know PHP but I have some basic programming understanding.
If you mind, please let this thread open for if someone has faced this issue and can help, or so that I can post a solution that anyone can profit from in hopefully a few days when i figure this out.
Thanks in advance,
Abel
May 3, 2020 at 11:59 pm #80529wzpModeratorAre you able to use URL links?
May 9, 2020 at 6:15 am #80530stalyanParticipantI added this code to functions.php of my theme and it solved the problem.
function AddToCartByProductID( $atts ) {
$args= shortcode_atts(
array (
‘id’ => 0
),
$atts );
return get_button_code_for_product($args);
}
add_shortcode( ‘add_to_cart_by_prod_id’, ‘AddToCartByProductID’);
Thanks for your help this thread can be closed if you want.
-
AuthorPosts
- You must be logged in to reply to this topic.