Plugin Directory

Changeset 1677321


Ignore:
Timestamp:
06/13/2017 08:46:46 AM (9 years ago)
Author:
labschool
Message:

1.0.7

Location:
pixel-de-facebook-para-wocommerce/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • pixel-de-facebook-para-wocommerce/trunk/fb-admin.php

    r1674924 r1677321  
    9797    $id = $options['product_ref'];
    9898    echo "<div id='col3'>Configuraci&oacute;n Avanzada</div>";
    99     echo "<!--<div id='col1'><label><strong>Identificador de producto</strong></label>-->
    100           <!--<div class='instruccion'>Puedes identificar la referencia del producto mediante el ID de Wordpress o el SKU que hayas definido.</div></div>-->";
    101     echo "<!--<div id='col2'><select name='pfb_woo_options[product_ref]'><option value='1' " . selected( $id , 1,false) . ">ID Producto</option><option value='0' " . selected( $id , 0,false) . ">SKU</option></div>-->";
     99    echo "<div id='col1'><label><strong>Identificador de producto</strong></label>
     100          <div class='instruccion'>Puedes identificar la referencia del producto mediante el ID de Wordpress o el SKU que hayas definido.</div></div>";
     101    echo "<div id='col2'><select name='pfb_woo_options[product_ref]'><option value='1' " . selected( $id , 1,false) . ">ID Producto</option><option value='0' " . selected( $id , 0,false) . ">SKU</option></div>";
    102102}
    103103
  • pixel-de-facebook-para-wocommerce/trunk/fb-conf.php

    r1674925 r1677321  
    44Plugin URI: https://www.labschool.es
    55Description: Agrega f&aacute;cilmente el p&iacute;xel de Facebook y los eventos de producto a tu tienda online con Woocommerce (ViewContent, AddToCart, InitiateCheckout y Purchase).
    6 Version: 1.0.6
     6Version: 1.0.7
    77Author: Lab School
    88Author URI: https://www.labschool.es
     
    6565            if( is_product() ){
    6666                $options = get_option('pfb_woo_options');
    67                 $sku = $product->get_sku();
    68                 $id = $product->get_id();
     67                $content_sku = $product->get_sku();
     68                $content_id = $product->get_id();
    6969                $name = $product->get_title();
    7070?>
     
    7474    content_type:   'product',
    7575    content_name:   '<?php echo $name ?>',
    76     content_ids:    ['<?php echo $id;/*(isset($options['product_ref']) && $options['product_ref']) ? $id : $sku;*/ ?>']
     76    content_ids:    ['<?php echo (isset($options['product_ref']) && $options['product_ref']) ? $content_id : $content_sku; ?>']
    7777});
    7878</script>
     
    8585    if (!isset($options['add_to_cart']) != '1' || $options['add_to_cart'] ) {
    8686        add_action( 'wp_footer', 'fb_addtocart' );
    87         function fb_addtocart( $product_id ) {
     87        function fb_addtocart( ) {
    8888           
    8989            if( is_cart() ){       
     
    9393                $cart_prods = WC()->cart->get_cart();
    9494               
    95                 if($cart_items) foreach ($cart_items as $cart_item){
    96                     $item[] = "'".$cart_item['product_id']."'";
    97                 }
    98                
    99                 $content_ids = implode( ', ',$item);
    100                
    101                 /*if($cart_prods) foreach ($cart_prods as $cart_prod){
    102                     $product_variation_id = $cart_prod['variation_id'];
    103                    
    104                     if ($product_variation_id) {
    105                         $prod = new WC_Product($cart_prod['variation_id']);
    106                     } else {
    107                         $prod = new WC_Product($cart_prod['product_id']);
    108                     }
    109                    
    110                     $sku[] = "'".$prod->get_sku()."'";                 
    111                 }*/
     95                if($cart_items) foreach ($cart_items as $cart_item){
     96                    $content_id[] = "'".$cart_item['product_id']."'";
     97                    $content_sku[] = "'".$cart_item['data']->get_sku()."'";
     98                }               
    11299?>
    113100<!-- Facebook AddToCart event -->
     
    115102fbq('track', 'AddToCart', {
    116103    content_type: 'product',
    117     content_ids: [<?php echo $content_ids; /*(isset($options['product_ref']) && $options['product_ref']) ? implode( ', ',$item) : implode( ', ',$sku);*/ ?>],
     104    content_ids: [<?php echo (isset($options['product_ref']) && $options['product_ref']) ? implode( ', ',$content_id) : implode( ', ',$content_sku); ?>],
    118105    value: <?php echo $cart_total ?>,
    119106    currency:'<?php echo $options['currency'];?>'
     
    137124               
    138125                if($cart_items) foreach ($cart_items as $cart_item){
    139                     $item[] = "'".$cart_item['product_id']."'";
    140                 }
    141                
    142                 $content_ids = implode( ', ',$item);
    143                
    144                 /*if($cart_prods) foreach ($cart_prods as $cart_prod){
    145                     $product_variation_id = $cart_prod['variation_id'];
    146                    
    147                     if ($product_variation_id) {
    148                         $prod = new WC_Product($cart_prod['variation_id']);
    149                     } else {
    150                         $prod = new WC_Product($cart_prod['product_id']);
    151                     }
    152                    
    153                     $sku[] = "'".$prod->get_sku()."'";                 
    154                 }*/
     126                    $content_id[] = "'".$cart_item['product_id']."'";
     127                    $content_sku[] = "'".$cart_item['data']->get_sku()."'";
     128                }   
    155129?>
    156130<!-- Facebook InitiateCheckout event -->
     
    158132fbq('track', 'InitiateCheckout', {
    159133    content_type: 'product',
    160     content_ids: [<?php echo $content_ids; /*(isset($options['product_ref']) && $options['product_ref']) ? implode( ', ',$item) : implode( ', ',$sku);*/ ?>],
     134    content_ids: [<?php echo (isset($options['product_ref']) && $options['product_ref']) ? implode( ', ',$content_id) : implode( ', ',$content_sku); ?>],
    161135    value: <?php echo $cart_total ?>,
    162136    currency:'<?php echo $options['currency'];?>'
     
    176150            $order = new WC_Order( $order_id );
    177151            $order_total = $order->get_total();
    178             $order_items = $order->get_items();
     152            $order_items = $order->get_items();         
    179153           
    180             if($order_items) foreach ($order_items as $order_item){
    181                 $item[] = "'".$order_item['product_id']."'";
    182                 /*$product_variation_id = $order_item['variation_id'];
    183                 if ($product_variation_id) {
    184                     $prod = new WC_Product($order_item['variation_id']);
    185                 } else {
    186                     $prod = new WC_Product($order_item['product_id']);
    187                 }
    188                 $sku[] = "'".$prod->get_sku()."'";*/
     154            if($order_items) foreach ($order_items as $order_item => $item){
     155                $content_id[] = "'".$item['product_id']."'";
     156                $content_sku[] = "'".$item->get_product()->get_sku()."'";               
    189157            }   
    190            
    191             $content_ids = implode( ', ',$item);
    192158?>
    193159<!-- Facebook Purchase event -->
     
    195161fbq('track', 'Purchase', {
    196162    content_type: 'product',
    197     content_ids: [<?php echo $content_ids; /*(isset($options['product_ref']) && $options['product_ref']) ? implode( ', ',$item) : implode( ', ',$sku);*/ ?>],
     163    content_ids: [<?php echo (isset($options['product_ref']) && $options['product_ref']) ? implode( ', ',$content_id) : implode( ', ',$content_sku); ?>],
    198164    value: <?php echo $order_total ?>,
    199165    currency:'<?php echo $options['currency'];?>'
  • pixel-de-facebook-para-wocommerce/trunk/readme.txt

    r1674924 r1677321  
    1818* Compatible con las versiones más recientes de Woocommerce +3.0.
    1919* Sencillo y fácil de configurar, en apenas unos segundos.
     20* Posibilidad de elegir entre ID de producto o SKU.
    2021* Posibilidad de activar/desactivar cada tipo de evento según la configuración de tu tienda online.
    2122* Ocupa menos de 20 Kb para interferir al mínimo en el rendimiento de tu web.
Note: See TracChangeset for help on using the changeset viewer.