예제 #1
0
function add_to_cart_shortcode($content = '')
{
    //exit($content);
    if (preg_match_all("/\\[add_to_cart=([\\d]+)\\]/", $content, $matches)) {
        foreach ($matches[1] as $key => $product_id) {
            $original_string = $matches[0][$key];
            $output = wpsc_add_to_cart_button($product_id, true);
            $content = str_replace($original_string, $output, $content);
        }
    }
    return $content;
}
예제 #2
0
function add_to_cart_shortcode($content = '')
{
    static $fancy_notification_output = false;
    if (!in_the_loop()) {
        return $content;
    }
    if (preg_match_all("/\\[add_to_cart=([\\d]+)\\]/", $content, $matches)) {
        foreach ($matches[1] as $key => $product_id) {
            $original_string = $matches[0][$key];
            $output = wpsc_add_to_cart_button($product_id, true);
            $content = str_replace($original_string, $output, $content);
        }
        if (!$fancy_notification_output) {
            $content .= wpsc_fancy_notifications(true);
            $fancy_notification_output = true;
        }
    }
    return $content;
}