Changeset 1677321
- Timestamp:
- 06/13/2017 08:46:46 AM (9 years ago)
- Location:
- pixel-de-facebook-para-wocommerce/trunk
- Files:
-
- 3 edited
-
fb-admin.php (modified) (1 diff)
-
fb-conf.php (modified) (10 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
pixel-de-facebook-para-wocommerce/trunk/fb-admin.php
r1674924 r1677321 97 97 $id = $options['product_ref']; 98 98 echo "<div id='col3'>Configuració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>"; 102 102 } 103 103 -
pixel-de-facebook-para-wocommerce/trunk/fb-conf.php
r1674925 r1677321 4 4 Plugin URI: https://www.labschool.es 5 5 Description: Agrega fácilmente el píxel de Facebook y los eventos de producto a tu tienda online con Woocommerce (ViewContent, AddToCart, InitiateCheckout y Purchase). 6 Version: 1.0. 66 Version: 1.0.7 7 7 Author: Lab School 8 8 Author URI: https://www.labschool.es … … 65 65 if( is_product() ){ 66 66 $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(); 69 69 $name = $product->get_title(); 70 70 ?> … … 74 74 content_type: 'product', 75 75 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; ?>'] 77 77 }); 78 78 </script> … … 85 85 if (!isset($options['add_to_cart']) != '1' || $options['add_to_cart'] ) { 86 86 add_action( 'wp_footer', 'fb_addtocart' ); 87 function fb_addtocart( $product_id) {87 function fb_addtocart( ) { 88 88 89 89 if( is_cart() ){ … … 93 93 $cart_prods = WC()->cart->get_cart(); 94 94 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 } 112 99 ?> 113 100 <!-- Facebook AddToCart event --> … … 115 102 fbq('track', 'AddToCart', { 116 103 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); ?>], 118 105 value: <?php echo $cart_total ?>, 119 106 currency:'<?php echo $options['currency'];?>' … … 137 124 138 125 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 } 155 129 ?> 156 130 <!-- Facebook InitiateCheckout event --> … … 158 132 fbq('track', 'InitiateCheckout', { 159 133 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); ?>], 161 135 value: <?php echo $cart_total ?>, 162 136 currency:'<?php echo $options['currency'];?>' … … 176 150 $order = new WC_Order( $order_id ); 177 151 $order_total = $order->get_total(); 178 $order_items = $order->get_items(); 152 $order_items = $order->get_items(); 179 153 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()."'"; 189 157 } 190 191 $content_ids = implode( ', ',$item);192 158 ?> 193 159 <!-- Facebook Purchase event --> … … 195 161 fbq('track', 'Purchase', { 196 162 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); ?>], 198 164 value: <?php echo $order_total ?>, 199 165 currency:'<?php echo $options['currency'];?>' -
pixel-de-facebook-para-wocommerce/trunk/readme.txt
r1674924 r1677321 18 18 * Compatible con las versiones más recientes de Woocommerce +3.0. 19 19 * Sencillo y fácil de configurar, en apenas unos segundos. 20 * Posibilidad de elegir entre ID de producto o SKU. 20 21 * Posibilidad de activar/desactivar cada tipo de evento según la configuración de tu tienda online. 21 22 * 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.