Title: teleinternet's Replies | WordPress.org

---

# teleinternet

  [  ](https://wordpress.org/support/users/teleinternet/)

 *   [Profile](https://wordpress.org/support/users/teleinternet/)
 *   [Topics Started](https://wordpress.org/support/users/teleinternet/topics/)
 *   [Replies Created](https://wordpress.org/support/users/teleinternet/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/teleinternet/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/teleinternet/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/teleinternet/engagements/)
 *   [Favorites](https://wordpress.org/support/users/teleinternet/favorites/)

 Search replies:

## Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)

 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Jigoshop] Product permalink is wrong with Polylang](https://wordpress.org/support/topic/product-permalink-is-wrong-with-polylang/)
 *  [teleinternet](https://wordpress.org/support/users/teleinternet/)
 * (@teleinternet)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/product-permalink-is-wrong-with-polylang/#post-6117064)
 * Well this is the final version of the patcher it patches shop, cart product detail
   pages.
 * Making Jigoshop work with polylang
    ———————————-
 * Jigoshop :
    Ensure that automatic plugging generated pages (Cart, Checkout etc.)
   had no defined language, including the Shop manually created page and configured
   in Jigoshop. To do it, simply add a new language to polylang, mark those pages
   with it, and then delete the language.
 * Then do no use the Shop page as the trick is to generate one product per language(
   with the same SKU number) and asign each a language category then the ‘Shop’ 
   page will be a custom link in the menu to /?product_cat=language_category (e.
   g. en es fr etc.) this way you have one different link per language.
    Menu for
   shop (category language) menu = [http://myweb.com/?product_cat=%5Blangcat%5D](http://myweb.com/?product_cat=%5Blangcat%5D)
 * Polylang :
    Settings | Languages (polylang settings) | Settings URL Modifications:
   set language by content and delete /language/ from custom permalinks Mark all
   Custom taxonomies and Sync.
 * General:
    WP Settings | Permalinks: by default (works 100% with no need of js
   runtime patching)
 *  WP Settings | Permalinks: by name of the entry -> requires patch see below
    (
   Need of language pack)
 * 1.- This code enqueues the script, append it to de jigoshop_actions.php
 *     ```
       /*
   
       Cargador del script en el plugin Jigoshop
       Script loader for Jigoshop plugin
   
       (C) FHP Agosto 2015
   
       Añadir al final del fichero jigoshop_actions.php y crear el directorio js y copiar ahí el script my_script.js:
       Add this file at the end of jigoshop_actions.php create a js/ directory an copy there my_script.js:
   
       */
   
       /**
        * Proper way to enqueue scripts and styles
        */
       function my_scripts() {
       #       wp_register_style( 'style-name', get_stylesheet_uri(). '/css/custom-style.css'););
       #       wp_enqueue_style( 'style-name' ) ;
   
       #        wp_enqueue_script( 'my_script', get_template_directory_uri() . '/js/my_script.js', array(), '1.0.0', false );
   
       //echo '<!--'.JIGOSHOP_URL.'-->' ;
               wp_register_script( 'my_script', JIGOSHOP_URL . '/js/my_script.js', array(), '1.0.0', false );
               wp_enqueue_script( 'my_script' ) ;
       }
   
       add_action( 'wp_enqueue_scripts', 'my_scripts' );
       ```
   
 * 2.- This is my_script.js (the patcher) copy it to (a new) js directory into jigoshop
   plugin directory
 *     ```
       /*
       - - - - - - - - - - - - - - - -
   
       RUNTIME PATCH FOR WordPress Jigoshop + Polylang
   
       - - - - - - - -- - - - - - - - -
   
       Objetivo: Un script que cambia en tiempo de ejecución el enlace de la imagen del producto de .../product/... a .../producto/...
   
       Objective: A runtime script that changes broken links using Jigoshop & Polylang and wp entry name permalinks
   
       */
   
       var v_target  = 'product' ;
       var v_replace = 'producto' ; // here your wordpress default language translation to 'product'
       var v_string  = '' ;
       var v_lookup = new Object() ;
   
       function f_rtpatch_shop() {
       v_lookup = document.getElementsByClassName("products")[0].childNodes ;
       for (i = 1; i < v_lookup.length; i=i+2) {
           v_string = v_lookup[i].childNodes[1].href ;
           v_string = v_string.replace(v_target,v_replace) ;
           v_lookup[i].childNodes[1].href = v_string ;
       //    console.log(v_lookup[i].childNodes[1].href)
                                               }
                                   } ;
   
       function f_rtpatch_producto() {
       v_lookup = document.getElementsByClassName("products")[1].childNodes ;
       for (i = 1; i < v_lookup.length; i=i+2) {
           v_string = v_lookup[i].childNodes[1].href ;
           v_string = v_string.replace(v_target,v_replace) ;
           v_lookup[i].childNodes[1].href = v_string ;
       //    console.log(v_lookup[i].childNodes[1].href)
                                               }
                                   } ;
   
       function f_rtpatch_cart() {
       v_lookup = document.getElementsByClassName("shop_table cart")[0].getElementsByTagName("tbody")[0].getElementsByTagName("tr") ;
       for (i = 0; i < v_lookup.length; i++) {
           k=[3,5] ; for (j in k) {
           v_string = v_lookup[i].childNodes[k[j]].childNodes[1].href ;
           v_string = v_string.replace(v_target,v_replace) ;
           v_lookup[i].childNodes[k[j]].childNodes[1].href = v_string ;
       //    console.log(v_lookup[i].childNodes[k[j]].childNodes[1].href)
                                  }
                                               };
   
                                 } ;
   
       window.onload = function() {
       var v_switch = window.location.pathname ;
       var v_pattern = /^\/[^\/]*\/{0,1}/ ;
       if (v_switch.length > 1) { v_switch = v_pattern.exec(v_switch).toString(); };
       switch(v_switch) {
       	case "/":			f_rtpatch_shop() ; break ;
           case "/"+v_replace+"/":	f_rtpatch_producto() ; break ;
           case "/cart/":		f_rtpatch_cart() ; break ;
                        } ;
                                  } ;
       ```
   
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Jigoshop] Product permalink is wrong with Polylang](https://wordpress.org/support/topic/product-permalink-is-wrong-with-polylang/)
 *  [teleinternet](https://wordpress.org/support/users/teleinternet/)
 * (@teleinternet)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/product-permalink-is-wrong-with-polylang/#post-6117060)
 * Well I have developed a runtime patcher to avoid this problem. It is not a solution,
   just a patcher.
 * 1.- This code enqueues the script, append it to de jigoshop_actions.php
 *     ```
       function my_scripts() {
       echo '<!--'.JIGOSHOP_URL.'-->' ;
               wp_register_script( 'my_script', JIGOSHOP_URL . '/js/my_script.js', array(), '1.0.0', false );
               wp_enqueue_script( 'my_script' ) ;
       }
   
       add_action( 'wp_enqueue_scripts', 'my_scripts' );
       ```
   
 * 2.- This is my_script.js (the patcher) copy it to (a new) js directory into jigoshop
   plugin directory
 *     ```
       /*
       - - - - - - - - - - - - - - - -
   
       RUNTIME PATCH FOR WordPress Jigoshop + Polylang
   
       - - - - - - - -- - - - - - - - -
   
       Objetives: A script that changes at runtime the link value of product's image from .../product/... to .../producto/... (case for ES other languages change v_replace value). Changes occur for shop page and cart page.
   
       */
   
       var v_target  = 'product' ;
       var v_replace = 'producto' ;
       var v_string  = '' ;
   
       function f_rtpatch_shop() {
       console.log('RUNTIME PATCH for Jigoshop + Polylang  |  shop') ;
       v_lookup = document.getElementsByClassName("products")[0].childNodes ;
   
       for (i = 1; i < v_lookup.length; i=i+2) {
           v_string = v_lookup[i].childNodes[1].href ;
           v_string = v_string.replace(v_target,v_replace) ;
           v_lookup[i].childNodes[1].href = v_string ;
          //console.log(v_lookup[i].childNodes[1].href)
                                               }
   
                                   } ;
   
       function f_rtpatch_cart() {
       console.log('RUNTIME PATCH for Jigoshop + Polylang  |  cart') ;
       v_lookup = v_lookup = document.getElementsByClassName("shop_table cart")[0].getElementsByTagName("tbody")[0].getElementsByTagName("tr") ;
   
       for (i = 0; i < v_lookup.length; i++) {
           k=[3,5] ; for (j in k) {
           v_string = v_lookup[i].childNodes[k[j]].childNodes[1].href ;
           v_string = v_string.replace(v_target,v_replace) ;
           v_lookup[i].childNodes[k[j]].childNodes[1].href = v_string ;
           //console.log(v_lookup[i].childNodes[k[j]].childNodes[1].href)
                                  }
                                               }
                                 } ;
   
       window.onload = function() {
       var v_switch = window.location.pathname ;
       switch(v_switch) {
           case "/shop/" : f_rtpatch_shop() ; break ;
           case "/cart/" : f_rtpatch_cart()
                                       }
                                   }
       ```
   
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Jigoshop] Product permalink is wrong with Polylang](https://wordpress.org/support/topic/product-permalink-is-wrong-with-polylang/)
 *  [teleinternet](https://wordpress.org/support/users/teleinternet/)
 * (@teleinternet)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/product-permalink-is-wrong-with-polylang/#post-6117058)
 * I have the same problem with polylang activated (in a non en language) the link
   of the product image says …/product/.. and it should be …/producto/… (in case
   of ES language for example).
 * The same happends with the link (image and text) at the cart section.
 * If I deactivate polylang it works.

Viewing 3 replies - 1 through 3 (of 3 total)