Ejemplo n.º 1
0
function ps_print_wp_shopping_cart()
{
    if (!ps_cart_not_empty()) {
        return;
    }
    $email = get_bloginfo('admin_email');
    $defaultEmail = get_option('cart_moip_email');
    $moip_symbol = 'R$';
    $url_images = get_bloginfo('wpurl') . "/wp-content/plugins/wp-moip/images/";
    if (!empty($defaultEmail)) {
        $email = $defaultEmail;
    }
    $decimal = '.';
    $urls = '';
    $title = get_option('wp_cart_title');
    if (empty($title)) {
        $title = 'Suas compras';
    }
    $output .= '<div class="shopping_cart" style=" padding: 5px;">';
    $output .= "<input type='image' src='" . get_bloginfo('wpurl') . "/wp-content/plugins/wordpress-carrinho-moip/images/moip_checkout.png' value='Carrinho' title='Carrinho' />";
    $output .= "<h2>";
    $output .= $title;
    $output .= "</h2>";
    $output .= "<br /><span id='pinfo' class='msg_alent' style='display: none; font-weight: bold;'><img src='" . get_bloginfo('wpurl') . "/wp-content/plugins/wordpress-carrinho-moip/images/info.png' />Pressione ENTER para atualizar a quantidade.</span>";
    $output .= '<table style="width: 100%;" border="0">';
    $count = 1;
    $total_items = 0;
    $total = 0;
    $form = '';
    if ($_SESSION['pssimpleCart'] && is_array($_SESSION['pssimpleCart'])) {
        $output .= '
        <tr>
        <th>Produto</th><th><center>Qtde</center></th><th><center>Valor</center></th>
        </tr>';
        foreach ($_SESSION['pssimpleCart'] as $item) {
            $total += $item['valor'] * $item['quantity'];
            $total_items += $item['quantity'];
            $item['total'] == $total;
        }
        foreach ($_SESSION['pssimpleCart'] as $item) {
            $output .= "\r\n        <tr><td class='wp_cart_campo' style='overflow: hidden;'><a href='" . $item['cartLink'] . "'>" . $item['name'] . "</a></td>\r\n        <td style='text-align: center'><form method=\"post\"  action=\"\" name='pcquantity' style='display: inline'>\r\n        <input type='hidden' class='wp_cart_campo' name='product' value='" . $item['name'] . "' />\r\n        <input type='hidden' name='cquantity' value='1' /><input type='text' class='wp_cart_input' name='quantity' value='" . $item['quantity'] . "' size='1' onchange='document.pcquantity.submit();' onkeypress='document.getElementById(\"pinfo\").style.display = \"\";' /></form></td>\r\n        <td class='wp_cart_campo' style='text-align: center'>" . ps_print_payment_currency($item['valor'] * $item['quantity'], $moip_symbol, $decimal) . "</td>\r\n        <td><form method=\"post\"  action=\"\">\r\n        <input type='hidden' name='product' value='" . $item['name'] . "' />\r\n        <!--<input type='hidden' name='product' value='" . $pieces['0'] . "' />-->\r\n        <input type='hidden' name='delcart' value='1' />\r\n        <input type='image' class='wp_cart_button' src='" . get_bloginfo('wpurl') . "/wp-content/plugins/wordpress-carrinho-moip/images/btn_delete.png' value='Remove' title='Remover' />\r\n         </form></td></tr>\r\n        ";
            $form .= "\r\n            <input type=\"hidden\" name=\"nome\" value=\"Total de [" . $total_items . "] produtos.\" />\r\n            <input type=\"hidden\" name=\"valor\" value='" . trata_valor($total) . "' />\r\n            <input type='hidden' name='descricao' value='Adquiridos no site [" . ps_cart_current_page_url() . "], produto indicativo [" . $item['name'] . "].' />\r\n        ";
            $form .= "<input type=\"hidden\" name=\"frete\" value=\"0\" />";
            $count++;
        }
    }
    $count--;
    if ($count) {
        $output .= '<tr><td></td><td></td><td></td></tr>';
        $output .= "\r\n    <tr><td colspan='2' style='font-weight: bold; text-align: right;'>Total: </td><td style='text-align: center'>" . ps_print_payment_currency($total, $moip_symbol, $decimal) . "</td><td></td></tr>\r\n    <tr><td colspan='4'>";
        $url = get_option('mn_check_sandbox') == 1 ? "https://desenvolvedor.moip.com.br/sandbox/PagamentoMoIP.do" : "https://www.moip.com.br/PagamentoMoIP.do";
        $output .= "<form action=\"{$url}\" target=\"moip\" method=\"post\">{$form}";
        if ($count) {
            $output .= '<input type="image" class="wp_cart_button" src="https://www.moip.com.br/imgs/buttons/bt_pagar_c01_e04.png" name="submit" alt="MoIP" />';
        }
        $output .= $urls . '
        <input type="hidden" name="id_carteira" value="' . get_option("mn_moip_email") . '" />
        </form>';
    }
    $output .= "\r\n</td></tr>\r\n</table></div>\r\n";
    $output .= '
    <script type="text/javascript" >

        var $k = jQuery.noConflict();
        var loadUrl = "/wp-content/plugins/wp-moip/wp-shopping-ajax.php";
        var ajax_load = "<img src=\'images/loading.gif\' alt=\'loading...\' />";
        

        $k(document).ready(function() {

            var data = {
                action: "pedido"                
            };
            
            $k(window).load(function() {
                $k(".shopping_cart").html(ajax_load).load(loadUrl);
                return false;
            });
        });
    </script>
    ';
    return $output;
}
Ejemplo n.º 2
0
function ps_print_wp_shopping_cart()
{
    if (!ps_cart_not_empty()) {
        return;
    }
    $email = get_bloginfo('admin_email');
    $defaultEmail = get_option('cart_pagseguro_email');
    $pagseguro_symbol = 'R$';
    if (!empty($defaultEmail)) {
        $email = $defaultEmail;
    }
    $decimal = '.';
    $urls = '';
    $title = get_option('wp_cart_title');
    if (empty($title)) {
        $title = 'Suas compras';
    }
    $output .= '<div class="shopping_cart" style=" padding: 5px;">';
    $output .= "<input type='image' src='" . get_bloginfo('wpurl') . "/wp-content/plugins/wordpress-pagseguro-shopping-cart/images/shopping_cart_icon.gif' value='Carrinho' title='Carrinho' />";
    $output .= "<h2>";
    $output .= $title;
    $output .= "</h2>";
    $output .= '<br /><span id="pinfo" style="display: none; font-weight: bold; color: red;">Pressione ENTER para atualizar a quantidade.</span>';
    $output .= '<table style="width: 100%;">';
    $count = 1;
    $total_items = 0;
    $total = 0;
    $form = '';
    if ($_SESSION['pssimpleCart'] && is_array($_SESSION['pssimpleCart'])) {
        $output .= '
        <tr>
        <th>Descrição</th><th>Qtde</th><th>Preço</th>
        </tr>';
        foreach ($_SESSION['pssimpleCart'] as $item) {
            $total += $item['price'] * $item['quantity'];
            $total_items += $item['quantity'];
        }
        foreach ($_SESSION['pssimpleCart'] as $item) {
            $output .= "                 \n        <tr><td style='overflow: hidden;'><a href='" . $item['cartLink'] . "'>" . $item['name'] . "</a></td>\n        <td style='text-align: center'><form method=\"post\"  action=\"\" name='pcquantity' style='display: inline'>\n        <input type='hidden' name='product' value='" . $item['name'] . "' />\n        \n        <input type='hidden' name='cquantity' value='1' /><input type='text' name='quantity' value='" . $item['quantity'] . "' size='1' onchange='document.pcquantity.submit();' onkeypress='document.getElementById(\"pinfo\").style.display = \"\";' /></form></td>\n        <td style='text-align: center'>" . ps_print_payment_currency($item['price'] * $item['quantity'], $pagseguro_symbol, $decimal) . "</td>\n        <td><form method=\"post\"  action=\"\">\n        <input type='hidden' name='product' value='" . $item['name'] . "' />\n        <input type='hidden' name='delcart' value='1' />\n        <input type='image' src='" . get_bloginfo('wpurl') . "/wp-content/plugins/wordpress-pagseguro-shopping-cart/images/Shoppingcart_delete.gif' value='Remove' title='Remover' /></form></td></tr>\n        \n        ";
            $form .= "\n            <input type=\"hidden\" name=\"item_descr_{$count}\" value=\"" . $item['name'] . "\" />\n            <input type=\"hidden\" name=\"item_valor_{$count}\" value='" . str_replace('.', '', $item['price']) . "' />\n            <input type=\"hidden\" name=\"item_quant_{$count}\" value=\"" . $item['quantity'] . "\" />\n            <input type='hidden' name='item_id_{$count}' value='" . $count . "' />\n        ";
            $form .= "<input type=\"hidden\" name=\"item_frete_{$count}\" value=\"0\" />";
            $count++;
        }
    }
    $count--;
    if ($count) {
        $output .= '<tr><td></td><td></td><td></td></tr>';
        $output .= "\n       \t\t<tr><td colspan='2' style='font-weight: bold; text-align: right;'>Total: </td><td style='text-align: center'>" . ps_print_payment_currency($total, $pagseguro_symbol, $decimal) . "</td><td></td></tr>\n       \t\t<tr><td colspan='4'>";
        $output .= "<form action=\"https://pagseguro.uol.com.br/security/webpagamentos/webpagto.aspx\" method=\"post\">{$form}";
        if ($count) {
            $output .= '<input type="image" src="' . get_bloginfo('wpurl') . '/wp-content/plugins/wordpress-pagseguro-shopping-cart/images/pagseguro_checkout.png" name="submit" alt="Pague com Pagseguro - é rápido, simples e seguro!" />';
        }
        $output .= $urls . '
			    <input type="hidden" name="email_cobranca" value="' . $email . '" />
          <input type="hidden" name="tipo" value="CP">
          <input type="hidden" name="moeda" value="BRL">
			    </form>';
    }
    $output .= "\n       \n       \t</td></tr>\n    \t</table></div>\n    \t";
    return $output;
}
Ejemplo n.º 3
0
function trata_valor($total)
{
    $total_valor = ps_print_payment_currency($total, "", "");
    return str_replace(',', '', $total_valor);
    return str_replace('.', '', $total_valor);
}