function eStore_get_gateway_specific_buy_now_button_code($id, $gateway = 'paypal', $button_text = '', $line_break = true, $nggImage = '', $buttonImage = '') { global $wpdb; $products_table_name = WP_ESTORE_PRODUCTS_TABLE_NAME; $id = strip_tags($id); $ret_product = $wpdb->get_row("SELECT * FROM {$products_table_name} WHERE id = '{$id}'", OBJECT); if (!$ret_product) { return eStore_wrong_product_id_error_msg($id); } $replacement = ""; if (is_numeric($ret_product->available_copies)) { if ($ret_product->available_copies < 1) { // No more copies left return eStore_get_sold_out_button(); } } if (!empty($ret_product->target_button_url)) { $replacement = '<form method="post" action="' . $ret_product->target_button_url . '">'; $replacement .= eStore_get_buy_now_submit_input($ret_product->button_image_url); $replacement .= '</form>'; return $replacement; } if (isset($_SESSION['eStore_gs_bn_co_error_msg']) && $_REQUEST['item_number'] == $id) { $replacement .= $_SESSION['eStore_gs_bn_co_error_msg']; } //$replacement .= '<object class="eStore_button_object">'; $replacement .= '<form method="post" class="wppg-eStore-buy-button-form" action="" style="display:inline" onsubmit="return ReadForm1(this, 1);">'; $var_output = get_variation_and_input_code($ret_product, $line_break, 1, $nggImage); if (!empty($var_output)) { $replacement .= $var_output; } //If custom price option is set if ($ret_product->custom_price_option == '1') { $currSymbol = WP_ESTORE_CURRENCY_SYMBOL; //get_option('cart_currency_symbol'); $replacement .= '<div class="wppg-eStore-buy-button-custom-price">' . WP_ESTORE_YOUR_PRICE . ': ' . $currSymbol . '<input type="text" name="custom_price" size="3" value="" /></div>'; } if ($ret_product->show_qty == '1') { $replacement .= '<div class="wppg-eStore-buy-button-qty">' . eStore_get_default_purchase_qty_input_data() . '</div>'; } else { $replacement .= '<div class="wppg-eStore-buy-button-qty"><input type="hidden" name="add_qty" value="1" /></div>'; } if (!empty($nggImage->alttext)) { $replacement .= '<input type="hidden" name="product" value="' . htmlspecialchars($nggImage->alttext) . '" /><input type="hidden" name="product_name_tmp1" value="' . htmlspecialchars($nggImage->alttext) . '" />'; } else { $replacement .= '<input type="hidden" name="product" value="' . htmlspecialchars($ret_product->name) . '" /><input type="hidden" name="product_name_tmp1" value="' . htmlspecialchars($ret_product->name) . '" />'; } if (!empty($nggImage->thumbURL)) { //$nggImage->imageURL $replacement .= '<input type="hidden" name="thumbnail_url" value="' . $nggImage->thumbURL . '" />'; } else { $replacement .= '<input type="hidden" name="thumbnail_url" value="' . $ret_product->thumbnail_url . '" />'; } $replacement .= '<input type="hidden" name="price" value="' . $ret_product->price . '" /><input type="hidden" name="price_tmp1" value="' . $ret_product->price . '" />'; $replacement .= '<input type="hidden" name="item_number" value="' . $ret_product->id . '" /><input type="hidden" name="shipping" value="' . $ret_product->shipping_cost . '" /><input type="hidden" name="tax" value="' . $ret_product->tax . '" />'; if (!empty($ret_product->product_url)) { $replacement .= '<input type="hidden" name="cartLink" value="' . $ret_product->product_url . '" />'; } else { $replacement .= '<input type="hidden" name="cartLink" value="' . digi_cart_current_page_url() . '" />'; } if (wp_eStore_is_digital_product($ret_product)) { //flag this as a digital product $replacement .= '<input type="hidden" name="digital_flag" value="1" />'; } $replacement .= '<input type="hidden" name="eStore_gsbn_gateway" value="' . $gateway . '" />'; $replacement .= '<input type="hidden" name="eStore_gs_buy_now_submit" value="1" />'; if (empty($buttonImage)) { $buttonImage = $ret_product->button_image_url; } if (!empty($buttonImage)) { $replacement .= eStore_get_buy_now_submit_input($buttonImage); } else { $replacement .= eStore_get_buy_now_submit_input("", $button_text); } $replacement .= '</form>'; //$replacement .= '</object>'; return $replacement; }
function eStore_donate_button_code($args) { extract(shortcode_atts(array('id' => 'no id', 'button_text' => ''), $args)); global $wpdb; $products_table_name = WP_ESTORE_PRODUCTS_TABLE_NAME; $ret_product = $wpdb->get_row("SELECT * FROM {$products_table_name} WHERE id = '{$id}'", OBJECT); if (!$ret_product) { return eStore_wrong_product_id_error_msg($id); } if (!empty($ret_product->paypal_email)) { $paypal_email = $ret_product->paypal_email; } else { $paypal_email = get_option('cart_paypal_email'); } if (!empty($ret_product->currency_code)) { $paypal_currency = $ret_product->currency_code; } else { $paypal_currency = get_option('cart_payment_currency'); } $return = $ret_product->return_url; if (empty($return)) { $return = get_option('cart_return_from_paypal_url'); } // Find out if the product should be delivered automatically through a notify email if (get_option('eStore_auto_product_delivery') == '') { $notify = ''; } else { if (WP_ESTORE_ENABLE_NEW_CHECKOUT_REDIRECTION === '1') { $notify = WP_ESTORE_WP_SITE_URL . '/?estore_pp_ipn=process'; } else { $notify = WP_ESTORE_URL . '/paypal.php'; } } $sandbox_enabled = get_option('eStore_cart_enable_sandbox'); if ($sandbox_enabled) { $form_submit_url = PAYPAL_SANDBOX_URL; } else { $form_submit_url = PAYPAL_LIVE_URL; } $output = ""; $output .= '<form action="' . $form_submit_url . '" method="post">'; $output .= '<input type="hidden" name="charset" value="utf-8" />'; $output .= '<input type="hidden" name="business" value="' . $paypal_email . '">'; $output .= '<input type="hidden" name="cmd" value="_donations">'; $output .= '<input type="hidden" name="item_name" value="' . $ret_product->name . '">'; $output .= '<input type="hidden" name="item_number" value="' . $id . '">'; $price_amt = (double) $ret_product->price; if ($price_amt > 0) { //Fixed price donation $output .= '<input type="hidden" name="amount" value="' . $price_amt . '">'; } $output .= '<input type="hidden" name="currency_code" value="' . $paypal_currency . '">'; if (!empty($notify)) { $output .= '<input type="hidden" name="notify_url" value="' . $notify . '">'; } $output .= '<input type="hidden" name="return" value="' . $return . '">'; if (defined('WP_ESTORE_FORCE_LANGUAGE_OF_PAYPAL_PAGE') && WP_ESTORE_FORCE_LANGUAGE_OF_PAYPAL_PAGE !== '0') { //Set the country/region preference by force. $output .= '<input type="hidden" name="lc" value="' . WP_ESTORE_FORCE_LANGUAGE_OF_PAYPAL_PAGE . '" />'; } $output .= aff_add_custom_field(); if (!empty($button_text)) { $sbmt_button_code = '<input type="submit" class="eStore_donate_button" value="' . __($button_text) . '" />'; } else { if (!empty($ret_product->button_image_url)) { $sbmt_button_code = '<input type="image" src="' . $ret_product->button_image_url . '" class="eStore_donate_button" alt="Donate"/>'; } else { $sbmt_button_code = '<input type="submit" class="eStore_donate_button" value="' . WP_ESTORE_DONATE . '" />'; } } $output .= $sbmt_button_code; $output .= '</form>'; return $output; }