Problem with add to cart shortcode in WPeCommerce 3.9.1
-
Store URL: not yet available
WordPress version: 4.1
WP eCommerce version: 3.9.1
Gold Cart version: –
Theme: custom and default themesHi,
I am trying to use the single product shortcode in a post that is output on the WordPress site separately through PHP code in the theme.The shortcode:
[add_to_cart=13]
The PHP code looks like this:
$post = get_post( 232 );
setup_postdata( $post );
the_content();
edit_post_link(” , ‘<p class=”edit”>’, ‘</p>’);
wp_reset_postdata( $post );The shortcode is simply written out in plain text which means it’s not recognized as a shortcode.
The shortcode works when it’s used on a normal page. All other shortcodes from WP eCommerce and other plugins work in the post, just not the add_to_cart shortcode that I need to get working.
I have tried disabling all plugins except WP eCommerce and changing to a different theme but it doesn’t help.
When searching on the issue I’ve seen mentioned some alternative (legacy?) shortcodes like wpsc_add_to_cart and wpsc-add-to-cart, but these don’t work either.
The latter shortcode is found in the wpsc-components/theme-engine-v2/helpers/shortcodes.php file which does not seem to be loaded at all. Instead it seems to use the wpsc-components/theme-engine-v1/helpers/shortcodes.php file. The similar wpsc_products shortcode that works fine is defined in the theme engine v1 helper. So I tried moving the wpsc-add-to-cart definition and function from theme engine v2 into theme engine v1 shortcodes.php. The function is obviously not compatible anymore as doesn’t output anything although the shortcode now is recognized and not written out as text.
I found the add_to_cart shortcode code in the file wpsc-components/theme-engine-v1/helpers/ajax.php and tried adding this function to the shortcodes.php file. Unfortunately this did not work at all and simply produced an error.
The core of the problem seems to be that the add_to_cart shortcode is defined in a way that differs from the other ones and so it’s not recognized to be used in any other part of the theme besides the main page content.
If someone could help me find a way to define the shortcode to be used elsewhere I would be grateful.
Thank you!
- The topic ‘Problem with add to cart shortcode in WPeCommerce 3.9.1’ is closed to new replies.