Forum Replies Created

Viewing 15 replies - 316 through 330 (of 1,795 total)
  • @whatthecup You can find the instructions to create a child theme here. There’s a lot of detail there, but it’s not as complicated as it seems, and almost always a good idea.

    Without knowing what modifications you’ve made, I can’t say what you’ll lose, but, for example, if you have added some custom CSS to Appearance -> Customize -> Additional CSS, you can just copy it and paste it into your child theme’s style.css and you’ll be good to go. Other than that, as noted in the article:

    You may need to re-save your menu from Appearance > Menus and theme options (including background and header images) after activating the child theme.

    It takes a little work the first time, but the whole point in having a child theme is that your modifications are preserved when you update the parent theme, so it will save you work in the long run, and enables you to make all kinds of custom changes easily.

    I couldn’t think of a way to do this with CSS, either.

    There’s also this option, which I haven’t tested in WC v. 4, but it sounds like a good alternative if you’re willing to add a child theme with its own functions.php. Not as simple as a translating plugin, but if you think you might use the word “dismiss” elsewhere…

    One way to do this is to create your own shortcode and add the following to your child theme’s functions.php:

    
    add_shortcode('custom_create_category_list', 'custom_create_category_list_fxn');
    function custom_create_category_list_fxn() {
      $args = array(
      'orderby'  => 'name',
      'order'    => 'asc',
      'hide_empty' => 1  // Change this to 0 to show empty categories.
       );
      
       $product_categories = get_terms( 'product_cat', $args );
      
       if(!empty($product_categories)){
       echo '<ul>';
         foreach ($product_categories as $key => $category) {
            echo '<li>';
            echo '<a href="'.get_term_link($category).'" >';
            echo $category->name;
            echo '</a>';
            echo '</li>';
          }
       echo '</ul>';
       }
    }
    

    Then, on the page where you want the list to appear, you’d add the following in a Shortcode Block:

    
    [custom_create_category_list]
    

    You didn’t mention if you only needed this to handle top-level categories or subcategories, too. This code just handles top-level categories.

    The JS Fiddle you linked to should work, it’s mainly going to take using the correct jQuery selector for your selects. That’s the tricky part.

    When I look at your problem page, it looks like the same ID, “stoerrelse” is used for the size selects for all items. That will cause problems with javascript/jQuery, because the ID attribute is supposed to be unique throughout an HTML document. You may need to fix that for other reasons, but it shouldn’t affect this.

    You might give the following selector in the JSFiddle code a try. It uses the body class “.woocommerce-page” to limit the change to your selects to that page, because your theme doesn’t include a page ID:

    
    ReplaceSelectWithButtons($('.woocommerce-page select'));
    

    A good way to test your selectors without disrupting things for your customers is to use the developer tools in Firefox or Chrome/Chromium to test the selectors with CSS; for example, I used the following to make sure I was getting all the selects on your problem page:

    
    .woocommerce-page select {
    	display: none !important;
    }
    

    Since it hid all the size selects when I tried it, I am (fairly) confident it will work in jQuery.

    There’s also the jQuery plugin Select2Buttons.

    Ideally, all the selects you want to change to buttons would share the same class, to make this easier, but they don’t. There may be a filter or hook to add a class to them.

    @polycellroot You’re welcome, though I’m not sure I helped. There are a couple things I should pass along.

    First of all, if you use the external/affiliate products to link to your landing page, you’re going to need to have a way for customers to purchase the products from the landing page when they arrive there. To do that, you’d have to create duplicate products of simple or variable product types with their catalog visibility set to “hidden” so they only show up on the landing page, not on the Shop page or search.

    An alternative that doesn’t require duplicate products would be to set a custom field called something like “landing_page_url” for the products you want to link to a landing page, then set the value of the field to the URL of the corresponding landing page. You can then use code to set the link to the product image when the products are displayed outside of the landing page to that URL if the meta value is present for a product.

    @creativ3y3 Let me know what you find out.

    Since the categories are a taxonomy, there’s a “woocommerce_product_query_tax_query” filter you may be able to use in conjunction with the above to limit the categories listed in the drop-down filter, and limit it to the Shop page.

    Have you seen this post?

    It seems like there should be an action that would govern both the initial display in the shop page and the filters. Maybe the action in the accepted answer, “woocommerce_product_query_meta_query,” might do it? It looks like it would alter any query passed to the shop page, and it’s a pretty simple way to handle your “sell_product_online” meta key.

    Hi @polycellroot

    I’m sorry! I did misunderstand what you are doing. That probably explains why it’s not working. The line:

    
    if(is_product_category()){
    

    is most likely returning “false” on that page, so the code isn’t firing.

    When you say the “WooCommerce Product widget,” do you mean A WooCommerce Block? I’m not using Elementor, but in my theme, if I use a WooCommerce Block, I get “Add to Cart” buttons, and I don’t see those in your screenshot.

    Hi @oringeverything

    You’re welcome! I’m glad you got it working.

    Maybe something like:

    
    action('woocommerce_order_status_changed', 'custom_order_status_change', 10, 3);
    function custom_order_status_change($order_id, $from_status, $to_status) {
      $order = wc_get_order($order_id);
      foreach ($order->get_items() as $item_id => $item_data) {
        $product = $item_data->get_product();
        // Get the data you need to compare to OtherStore2
        $product_id = $product->get_id();
        $product_name = $product->get_name(); 
    
        $item_quantity = $item_data->get_quantity();
        // Do your communicating here, or create an array of product ids and quantities and do it after this loop using the $to_status to determine the math.
      }
    }
    

    There is a hook (action) called “woocommerce_order_status_changed” that it looks like you could use in your child theme’s functions.php to check the order status, get the product id(s) involved in the order, and then run some PHP to communicate to OtherStore2.

    Nice work. I’m glad you got it working.

    Ordinarily, WooCommerce uses an AJAX call to set the available variations when you select a variation on which subsequent ones are dependent. For example, when you select the Model on your sample page, WooCommerce sends an AJAX call to the server to populate the Sub-model with the correct options. However, if you exceed the default 30 variations, WooCommerce doesn’t use AJAX, and you end up with options that don’t exist in the drop-down boxes, and your customers see the confusing “Sorry, this product is unavailable. Please choose a different combination.”

    The fix for that issue is to increase the default number of variations that are allowed to generate an AJAX call. To do that, figure out what your maximum number of variations will be, and add the following code snippet to your child theme’s functions.php:

    
    add_filter( 'woocommerce_ajax_variation_threshold', 'wc_ajax_variation_threshold' );
    	function wc_ajax_variation_threshold() {
    	    return 150;
    	}
    

    Change the “150” in the snippet to something higher than your maximum number of variations.

    Keep in mind that WooCommerce added the default of 30 to reduce the load on your server. If your server is underpowered and the threshold is set too high, you can end up with problems.

    Give that a try and see if it fixes both issue #1 and issue #2.

    I tried it a couple of times in Firefox, and it’s working okay for me. I can add an item to the Cart, go from the Cart page to Checkout, and the item is still there. I wasn’t logged in when I tried it, so maybe that’s related?

    You don’t mention what caching plugin you’re using, but I’ve had good luck with WP Super Cache, which I use successfully with a number of WooCommerce stores. It’s made by the same folks that make WooCommerce, which probably helps. If you suspect your caching plugin, you could try deactivating it first and re-testing. If it’s indeed the culprit, you can try WP Super Cache, or take a look in the support forum for the caching plugin to see if there are known issues.

    Adding the following code snippet into your child theme’s functions.php should do the trick:

    
    add_filter('woocommerce_get_availability', 'custom_get_availability', 1, 2);
    function custom_get_availability($availability, $product) {
      if ($availability['availability'] == '') {
        $availability['availability'] = __('In Stock', 'woocommerce');
      }
      return $availability;
    }
    

    This was discussed in detail in this post.

Viewing 15 replies - 316 through 330 (of 1,795 total)