Viewing 17 posts - 1 through 17 (of 17 total)
  • Author
    Posts
  • #639405

    Hi, I am having a problem while overriding the Woccommerce file form-shipping.php

    I must change the title “Shipping to a different address?” with something else (e.g. “Are you buying it for somebody else?”).

    I have read that Enfold doesn’t work with WC templates in the child theme.

    could you please help me to solve the thing? O wish not change the original file as changes would be lost with a future WC upgrade

    Thank you

    elena

    #639459

    Hey Elena,

    I would contact WC support about it.

    Best regards,
    Andy

    #639684

    Right now I solved it by changing the file shipping-form in woocommerce>templates>checkout at line 40

    from

    <label for=” (Purchase code hidden if logged out) ” class=”checkbox”><?php _e( ‘Shipping to a different address?’, ‘woocommerce’ );

    to
    <label for=” (Purchase code hidden if logged out) ” class=”checkbox”><?php _e( ‘Are you buying it for somebody else?’, ‘woocommerce’ );

    But it will be deleted once the I update the WC

    Thanks anyway

    #639695

    Hi!

    You can copy that file, inside your child theme folder with the same directory
    /woocommerce/checkout.php

    and that, will solve your issues.

    Thanks a lot for your understanding

    Cheers!
    Basilis

    #639700

    Hi Basilis, I tried, but it doesn’t work in the front-end. It only works it it stays in woocommerce original folder.

    #640265

    Hi,

    ask WooCommerce support about how to use this inside your child theme. They know their plugin best.

    Best regards,
    Andy

    #640559

    Hi Andy, I think I got it! Since it may serve for others I report here the procedure I adopted. Maybe you can also answer to a question (see at the bottom of the codes)

    First of all I created a new function on the file class-wc-product-variation.php that is found in woocommerce/includes/
    The function is more or less the modified copy of the get_formatted_name at line 741 of the file. My new function is called get_formatted_variations_name and returns a string which gives the title of the variation and the price. Here it is:

    STEP 1

    
    	/**
    	 * Get product variation name. Used within admin.
    	 *
    	 * @return string Formatted product name, including attributes and price
    	 */
    	public function get_formatted_variations_name() {
    		if ( $this->get_sku() ) {
    			$identifier = $this->get_sku();
    		} else {
    			$identifier = '';
    		}
    
    		$formatted_attributes = $this->get_formatted_variation_attributes( true );
    		$variation_name = substr($formatted_attributes, 27);
    		$extra_data           = $variation_name . ' &ndash; ' . wc_price( $this->get_price() );
    
    		return sprintf( __( '%s', 'woocommerce' ), $extra_data );
    	}
    

    STEP 2)
    I created a new avia element called “calendar’ in which I call the function stated before, together with the stock data in a loop, in order to extract all variation for a determined product. In my case the product was called “CSR Expeditions Payment” and the variations are the dates of the cruises. The $loop passes all the products, and before outputting the data I need, I filter the product of interest (in this case CSR Expeditions Payment).

     
    <?php
    if( !class_exists( 'woocommerce' ) )
    {
    	add_shortcode('csr_calendar_button', 'avia_please_install_woo');
    	return;
    }
    
    if ( !class_exists( 'avia_csr_calendar_button' ) )
    {
    	class avia_csr_calendar_button extends aviaShortcodeTemplate
    	{
    		/**
    		 * Create the config array for the shortcode button
    		 */
    		function shortcode_insert_button()
    		{
    			$this->config['name']		= __('CSR Calendar', 'avia_framework' );
    			$this->config['tab']		= __('Plugin Additions', 'avia_framework' );
    			$this->config['icon']		= AviaBuilder::$path['imagesURL']."sc-button.png";
    			$this->config['order']		= 23;
    			$this->config['target']		= 'avia-target-insert';
    			$this->config['shortcode'] 	= 'csr_calendar_button';
    			$this->config['tooltip'] 	= __('Display the "CSR Calnedar" button for the current product', 'avia_framework' );
    			$this->config['drag-level'] = 3;
    			$this->config['tinyMCE'] 	= array('disable' => "true");
    			$this->config['posttype'] 	= array('product',__('This element can only be used on single product pages','avia_framework'));
    		}
    
    		/**
    		 * Editor Element - this function defines the visual appearance of an element on the AviaBuilder Canvas
    		 * Most common usage is to define some markup in the $params['innerHtml'] which is then inserted into the drag and drop container
    		 * Less often used: $params['data'] to add data attributes, $params['class'] to modify the className
    		 *
    		 *
    		 * @param array $params this array holds the default values for $content and $args.
    		 * @return $params the return array usually holds an innerHtml key that holds item specific markup.
    		 */
    		function editor_element($params)
    		{
    			$params['innerHtml'] = "<img />config['icon']."' title='".$this->config['name']."' />";
    			$params['innerHtml'].= "<div class='avia-element-label'>".$this->config['name']."</div>";
    			$params['content'] 	 = NULL; //remove to allow content elements
    			return $params;
    		}
    
    		/**
    		 * Frontend Shortcode Handler
    		 *
    		 * @param array $atts array of attributes
    		 * @param string $content text within enclosing form of shortcode element
    		 * @param string $shortcodename the shortcode found, when == callback name
    		 * @return string $output returns the modified html string
    		 */
    		function shortcode_handler($atts, $content = "", $shortcodename = "", $meta = "")
    		{
    			$output = "";
    			$meta['el_class'];
    			
    			global $woocommerce, $product;
    			if(!is_object($woocommerce) || !is_object($woocommerce->query) || empty($product)) return;
    
    			// $product = wc_get_product();
    			
    			$output .= "<div class='av-woo-calendar-button ".$meta['el_class']."'>";
    			ob_start();?>
    			
                    <table cellspacing="0" cellpadding="2">
                        <thead>
                            <tr>
                                <th scope="col" style="text-align:left;"><?php _e('Cruise', 'woothemes'); ?></th>
                                <th scope="col" style="text-align:left;"><?php _e('Places availability', 'woothemes'); ?></th>
                            </tr>
                        </thead>
                        <tbody>
                        <?php
                        
                        $args = array(
                            'post_type'			=> 'product_variation',
                            'post_status' 		=> 'publish',
                            'posts_per_page' 	=> -1,
                            'orderby'			=> 'title',
                            'order'				=> 'DESC',
                            'meta_query' => array(
                                array(
                                    'key' 		=> '_stock',
                                    'value' 	=> array('', false, null),
                                    'compare' 	=> 'NOT IN'
                                )
                            )
                        );
                        
                        $loop = new WP_Query( $args );
                    
                        while ( $loop->have_posts() ) : $loop->the_post();
                        
                                        $product = new WC_Product_Variation( $loop->post->ID );
                                if (get_the_title( $loop->post->post_parent ) == 'CSR Expeditions Payment')
                                {		
                            ?>
                            <tr>
                                <td><?php  echo $product->get_formatted_variations_name(); ?></td>
                                <td><?php echo intval ($product->stock); ?></td>
                            </tr>
                            <?php
                                }
                        endwhile; 
                        
                        ?>
                        </tbody>
                    </table>
    		
    			<?php
    			
    			$output .= ob_get_clean();
    			$output .= "</div>";
    			
    			return $output;
    		}
    	}
    }
    

    CONSIDERATIONS

    1) It seems working by now, but I have to add it AFTER the product purchase button, otherwise the purchase button doesn’t appear… still have to figure out why

    2) I still am trying to see where I can save my new function in the child theme folde. I tried to add it to a subfolder woocommerce/includes, but it doesn’t work like that. By now I left the new function in the original woocommerce file class-wc-product-variation.php, but it is not a good solution as if I update the plugin the modifications would be lost. HERE’S MY QUESTION: do you know where I should save it??

    Thanks again
    Elena

    • This reply was modified 1 year, 5 months ago by  elenapoliti.
    #640564

    SORRY ANDY, I ANSWERED TO THE WRONG THREAD!!!! PLEASE DELETE MY ANSWER. I AM GOING TO PUBLISH IN THE PROPER ONE!!

    #640692

    Hi,

    No problem, so did you manage to solve the problem in this thread?

    Regards,
    Rikard

    #640722

    Hi Rikard, actually I still not solved the problem of woocommerce overriding. It seems that I should copy the WC modified files in my child theme folder, in a path like child-teme/woocommerce/templates/checkout, but it doesn’t work like that.

    I worked on modifying another file of woocommerce for my purposes (see wrong answer above) and still have the same problem…

    Elena

    #640842

    Hi,

    check out this and if you have any more questions feel free to ask WC support about it: https://support.woothemes.com/hc/en-us/articles/ (Purchase code hidden if logged out)(Purchase code hidden if logged out)

    Best regards,
    Andy

    #640855

    Yes I checked it out thank you. But that is not the case. My child theme works perfectly and my problem doesn’t relate to page templates or style sheet, but only to woocommerce files. I already managed with other themes to override woocommerce files by copying them in the child theme folder in the proper directory as reported in this post https://docs.woothemes.com/document/template-structure/

    Unfortunately this time it doesn’t work

    #640862

    Hi,

    does it work for you with a default WP theme?

    Best regards,
    Andy

    #640872

    Well it worked with another theme which is older than yours. I guess that I should work somewhere on your config.php for woocommerce, but really don’t know where.

    It doesn’t matter. I will keep the modified files in a backup folder and when WC is updated I will substitute the new files with my custom files

    #640899

    Hi,

    alright, good to know that you found a solution for you. Can we close this thread now?

    Best regards,
    Andy

    #640912

    yes thanks

    #641239

    Hi,

    Ok, thanks for letting us know.

    Regards,
    Rikard

Viewing 17 posts - 1 through 17 (of 17 total)

The topic ‘Override Woocommerce form-shipping.php file’ is closed to new replies.