Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author Pektsekye

    (@pektsekye)

    Hello,

    You can download the modified files on this page:
    “WPML find translated products”
    https://hottons.com/ymm_modifications_other

    Stanislav

    Thread Starter Periklis Kakarakidis

    (@perikliskakarakidis)

    Hello,

    Please make sure to check your emails,
    Also I can not find the moddification you enlisted on the moddifications page.

    Plugin Author Pektsekye

    (@pektsekye)

    Hello,

    Try to refresh your browser cache.

    It is at the end of the page now.

    Stanislav

    Thread Starter Periklis Kakarakidis

    (@perikliskakarakidis)

    Hello,

    I changed the file but still nothing shows up on the Original’s language products.
    Is a new import of the .csv needed for the DB to actually rewrite the data?

    Plugin Author Pektsekye

    (@pektsekye)

    Hello,

    This modification affects only the search results.

    Each product by ID has its own YMM restriction.
    Check if the database table has ymm restrictions for your product ID.

    Stanislav

    Thread Starter Periklis Kakarakidis

    (@perikliskakarakidis)

    Hello,

    Well the database has only post_id’s and then make,model,year_from,year_to .
    How can I make the vehicle fitment tab that is vissible on the Translated langauge be vissible on the Original language too?

    Thanks in advance,
    Periklis

    Plugin Author Pektsekye

    (@pektsekye)

    Hello,

    The post_id is the product ID in WooCommerce.
    So you should check if the product has restrictions in the database table by ID.

    Stanislav

    Thread Starter Periklis Kakarakidis

    (@perikliskakarakidis)

    Hello,

    Well the products in Original language do not have their product_id written in the database, thats why I asked if a new import is needed here.

    should I import them in the DB?

    Periklis

    Plugin Author Pektsekye

    (@pektsekye)

    Hello,

    You can add extra code to the “WPML find translated products” modification.

    Replace the code:

    
    public function getProductRestrictions($productId)     
        {
          $productId = (int) $productId;    
             
          $select = "
            SELECT make, model, year_from, year_to  
            FROM {$this->_mainTable} 
    		    WHERE product_id = {$productId} 
    		    ORDER BY make 	            
          ";
          
          return (array) $this->_wpdb->get_results($select, ARRAY_A);         
        }
    

    with:

    
    public function getProductRestrictions($productId)     
        {
    
          $restrictions = $this->_getProductRestrictions($productId);
          
          if (count($restrictions) == 0 && defined('WPML_PLUGIN_PATH')){    
            $trPIds = $this->getTranslatedIds(array($productId));        
            foreach($trPIds as $trPId){
              $restrictions = $this->_getProductRestrictions($trPId);
              if (count($restrictions) > 0){
                break;
              }
            }
          }
          
          return $restrictions;         
        }
    
         public function _getProductRestrictions($productId)     
        {
          $productId = (int) $productId;    
             
          $select = "
            SELECT make, model, year_from, year_to  
            FROM {$this->_mainTable} 
    		    WHERE product_id = {$productId} 
    		    ORDER BY make 	            
          ";
          
          return (array) $this->_wpdb->get_results($select, ARRAY_A);       
        }
    

    in the file:
    wp-content/plugins/ymm-search/Model/Db.php

    So that if the translated product does not have a ymm restriction then it will load and display the vehicle fitment from the original product.

    Stanislav

    Thread Starter Periklis Kakarakidis

    (@perikliskakarakidis)

    Thank you Stanislav,

    Problem solved!

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Ymm Restrictions show on database + fitment but only for the English Language.’ is closed to new replies.