/ Published in: PHP
I can\\'t this function to fire WordPress shortcodes or getmetadata:\r\n\r\nProblem 1. In the shortcode, if I remove \\'.$item.\\' and replace with it\\'s regular value that the post_meta holds (hard code it) this works just fine. Also the same with the $numb variable.\r\n\r\nHave any ideas why these variable aren\\'t working before they\\'re encoded?
Expand |
Embed | Plain Text
function discount() { global $post; $item = get_post_meta( $post->ID, 'item_number_discount', true ); $entry['code'] = "success"; $entry['link'] = '<a class="purchase discount" href="javascript:{}" onclick="document.getElementById(\'cartButtonForm_'. $numb .'\').submit(); return false;">Purchase discount</a>'; $entry['form'] = do_shortcode( '[cart-button item="'.$item.'" showprice="no" ]' ); $arr[] = $entry; } add_action( 'wp_ajax_add_discount', 'discount' ); //hook to ajax action add_action( 'wp_ajax_nopriv_add_discount', 'discount' ); //hook to ajax action
You need to login to post a comment.
