Forum Replies Created

Viewing 15 replies - 16 through 30 (of 281 total)
  • Thread Starter Cezar Ayran

    (@ayrancd)

    Tks y’all. That seems to be a theme thing and no they can’t be translated by using gettext, I’ve reached out to the Avada theme.

    Thread Starter Cezar Ayran

    (@ayrancd)

    @bcworkz but how am I going to add it to the media? Duplicate the file and the media info in the database.

    I am using media_handle_upload() to upload the file.

    Thread Starter Cezar Ayran

    (@ayrancd)

    That solved the issue @yordansoares

    Thread Starter Cezar Ayran

    (@ayrancd)

    UPDATE: this only happens when I set Shop header/logo, if I remove it, I can see the invoice… I tried to put a different image but all of them went through the same error.

    Thread Starter Cezar Ayran

    (@ayrancd)

    @threadi tks for clarifying it.

    Thread Starter Cezar Ayran

    (@ayrancd)

    @threadi I have some custom columns already tks but could you pls explain to me why changing an existing column content should be avoided?

    Thread Starter Cezar Ayran

    (@ayrancd)

    Just found a solution:

    function slug_save_post_callback( $post_ID, $post, $update ) {
        if ($post->post_type != 'product')
            return;
    
        $new_slug = sanitize_title( $post->post_title, $post_ID );
        if ($new_slug == $post->post_name)
            return; // already set
    
        // unhook this function to prevent infinite looping
        remove_action( 'save_post', 'slug_save_post_callback', 10, 3 );
        // update the post slug (WP handles unique post slug)
        wp_update_post( array(
            'ID' => $post_ID,
            'post_name' => $new_slug
        ));
        // re-hook this function
        add_action( 'save_post', 'slug_save_post_callback', 10, 3 );
    }
    add_action( 'save_post', 'slug_save_post_callback', 10, 3 );
    Thread Starter Cezar Ayran

    (@ayrancd)

    @threadi just tried the following code and the slug is not being updated at all

    wp_update_post(array('ID' => $id, 'post_name' => sanitize_title($_POST["product_title"])));

    I also tried it empty and no changes.

    • This reply was modified 1 year, 1 month ago by Cezar Ayran.
    Thread Starter Cezar Ayran

    (@ayrancd)

    I posted it on the main WP Forum and they told me to post it here.

    I posted it here and you are telling to go somewhere else.

    I give up.

    Thread Starter Cezar Ayran

    (@ayrancd)

    @t-p this is not just a WooCommerce question, I am using WP functions, as you can see the code has tons of removals and they are NOT all related to WooCommerce anyway.. I posted the same question on Woo plugin forum.

    • This reply was modified 1 year, 1 month ago by Cezar Ayran.
    Thread Starter Cezar Ayran

    (@ayrancd)

    tks @bcworkz

    Thread Starter Cezar Ayran

    (@ayrancd)

    the weird thing about this import is that it works most of the time but when it doesn’t work well it shuts down the whole website lol

    Thread Starter Cezar Ayran

    (@ayrancd)

    @bcworkz I just received a report from the server guy and the issue was being caused by another function that imports vehicles by reading a CSV file every 3 hours… this CSV is being run via CRON and sometimes it hits the server limits… I’m putting the code here to see if you or someone has a better idea of how to accomplish this task:

    //import CSV
    add_action("wp_ajax_fn_import_csv", "fn_import_csv");
    add_action( 'wp_ajax_nopriv_fn_import_csv', 'fn_import_csv' );
    
    $row = false;
    function fn_import_csv(){
        define('EXECUTION', uniqid());
        echo "Execution ".EXECUTION."<br><br>";
        update_option('inventory_update', current_time('m/d/Y h:i A')); //update settings field
        $file = fopen(ABSPATH."inventory/MP7220_website.csv", "r");
        while (($data = fgetcsv($file)) !== FALSE){
            if($row == true){
                //check if INSERT or UPDATE
                $rsCheck = array('posts_per_page' => 1, 'post_type' => 'inventory', 'post_status' => 'any', 'meta_query' => array('relation' => 'AND', array('key' => 'stock','value' => $data[1], 'compare' => '=')));
                $arCheck = get_posts($rsCheck);
    
                $title = $data[4]." ".$data[5]." ".$data[6]." ".$data[10]." ".$data[16];
                
                if(count($arCheck) == 0){ //insert inventory
                    echo "<b style='color:#2271b1'>INSERT</b> <i>".$data[1]."</i> - ".$title."<br>";
                    $id = wp_insert_post(array('post_title' => $title, 'post_type'=> 'inventory', 'post_status' => 'publish'));
                    $photosPieces = explode(";", $data[28]);
    
                    $photos = "";
                    for($i = 0; $i < count($photosPieces); $i++){
                        $photos .= "<img src='".$photosPieces[$i]."' style='height:100px!important'>";
                    }
                    add_post_meta($id, 'photos', $photos);
                    add_post_meta($id, 'photos_urls', $data[28]);
                    add_post_meta($id, 'has_photos', (count($photosPieces) == "1") ? "N" : "Y");
                    add_post_meta($id, 'stock', $data[1]);
                    add_post_meta($id, 'price', $data[19]);
                    add_post_meta($id, 'vin', $data[2]);
                    add_post_meta($id, 'newused', $data[3]);
                    add_post_meta($id, 'year', $data[4]);
                    add_post_meta($id, 'make', $data[5]);
                    add_post_meta($id, 'model', $data[6]);
                    add_post_meta($id, 'model_code', $data[7]);
                    add_post_meta($id, 'body', $data[8]);
                    add_post_meta($id, 'transmission', $data[9]);
                    add_post_meta($id, 'series', $data[10]);
                    add_post_meta($id, 'series_detail', $data[11]);
                    add_post_meta($id, 'door_count', $data[12]);
                    add_post_meta($id, 'odometer', $data[13]);
                    add_post_meta($id, 'engine_cylinder_ct', $data[14]);
                    add_post_meta($id, 'engine_displacement', $data[15]);
                    add_post_meta($id, 'drivetrain_desc', $data[16]);
                    add_post_meta($id, 'color', $data[17]);
                    add_post_meta($id, 'interior_color', $data[18]);
                    add_post_meta($id, 'description', $data[23]);
                    add_post_meta($id, 'features', $data[24]);
                    add_post_meta($id, 'city_mpg', $data[25]);
                    add_post_meta($id, 'highway_mpg', $data[26]);
                    add_post_meta($id, 'engine', $data[31]);
                    add_post_meta($id, 'fuel', $data[32]);
                    add_post_meta($id, 'execution', EXECUTION);
                    add_post_meta($id, 'lock_price_field', "No");
                    add_post_meta($id, 'pre_owned', "No");
    
                    $description = $title." ".$data[17]." for sale. Visit Major World in Long Island City #NY serving Queens, Brooklyn and Bronx #".$data[2];
                    add_post_meta($id, '_yoast_wpseo_metadesc', $description);
                }else{ //update inventory
                    $ar = json_decode(json_encode($arCheck), true);
                    echo "<b style='color:#4fb347'>UPDATE</b> <i>".$ar[0]["ID"]." - ".$data[1]."</i> - ".$title."<br>";
                    $id = $ar[0]["ID"];
                    $photosPieces = explode(";", $data[28]);
    
                    $photos = "";
                    for($i = 0; $i < count($photosPieces); $i++){
                        $photos .= "<img src='".$photosPieces[$i]."' style='height:100px!important'>";
                    }
                    wp_update_post(array('ID' => $id, 'post_title' => $title));
                    update_post_meta($id, 'photos', $photos);
                    update_post_meta($id, 'photos_urls', $data[28]);
                    update_post_meta($id, 'has_photos', (count($photosPieces) == "1") ? "N" : "Y");
                    update_post_meta($id, 'stock', $data[1]);
    
                    if(get_field("lock_price_field", $id) == "No" || get_field("lock_price_field", $id) == ""){ //only update the price if it is not locked
                        update_post_meta($id, 'price', $data[19]);
                    }
    
                    update_post_meta($id, 'vin', $data[2]);
                    update_post_meta($id, 'newused', $data[3]);
                    update_post_meta($id, 'year', $data[4]);
                    update_post_meta($id, 'make', $data[5]);
                    update_post_meta($id, 'model', $data[6]);
                    update_post_meta($id, 'model_code', $data[7]);
                    update_post_meta($id, 'body', $data[8]);
                    update_post_meta($id, 'transmission', $data[9]);
                    update_post_meta($id, 'series', $data[10]);
                    update_post_meta($id, 'series_detail', $data[11]);
                    update_post_meta($id, 'door_count', $data[12]);
                    update_post_meta($id, 'odometer', $data[13]);
                    update_post_meta($id, 'engine_cylinder_ct', $data[14]);
                    update_post_meta($id, 'engine_displacement', $data[15]);
                    update_post_meta($id, 'drivetrain_desc', $data[16]);
                    update_post_meta($id, 'color', $data[17]);
                    update_post_meta($id, 'interior_color', $data[18]);
                    update_post_meta($id, 'description', $data[23]);
                    update_post_meta($id, 'features', $data[24]);
                    update_post_meta($id, 'city_mpg', $data[25]);
                    update_post_meta($id, 'highway_mpg', $data[26]);
                    update_post_meta($id, 'engine', $data[31]);
                    update_post_meta($id, 'fuel', $data[32]);
    
                    $description = $title." ".$data[17]." for sale. Visit Major World in Long Island City #NY serving Queens, Brooklyn and Bronx #".$data[2];
                    update_post_meta($id, '_yoast_wpseo_metadesc', $description);
                    update_post_meta($id, 'execution', EXECUTION);
                }
            }else{
                $row = true;
            }
        }//end while
    
        //remove vehicles
        $argsD = array(
                'posts_per_page'  => -1,
                'post_type'       => 'inventory',
                'post_status'     => 'any',
                'suppress_filters' => false,
                'meta_query'    => array(
                    'relation'      => 'AND',
                    array(
                        'key'       => 'execution',
                        'value'     => EXECUTION,
                        'compare'   => '!='
                    )
                ),
        ); 
        $postsDelete = get_posts($argsD);
        echo "<br><br><h4>TO BE DELETED (".count($postsDelete).") - <i>".EXECUTION."</i></h4>";
        foreach ($postsDelete as $arD){
            echo "- ".get_the_title($arD->ID)." ".$arD->ID." <i>".get_field("stock", $arD->ID)."</i><br>";
            wp_delete_post($arD->ID);
        }
        //end remove vehicles
        wp_die(); //necessary to prevent 0 from being printed
    }//end import CSV
    Thread Starter Cezar Ayran

    (@ayrancd)

    @bcworkz tks for the suggestions.

    Thread Starter Cezar Ayran

    (@ayrancd)

    I’m assuming it is a DB issue but it is actually a php fpm processes causing issues … :/

Viewing 15 replies - 16 through 30 (of 281 total)