Forum Replies Created

Viewing 11 replies - 1 through 11 (of 11 total)
  • Thread Starter pandusen

    (@pandusen)

    Thanks. I dont need to display the value, I need it as a multiplayer for a another function, outside cpo.

    For instance, I need to get the Value of $length, from the cart item (which is a cpo product)

    I think the struggle is, that there is no documentation on how to get Variation Attributes from a Simple-Product.

    This snippet works for Variation-Products:

    function get_variation_data_from_variation_id( $item_id ) {
        $_product = new WC_Product_Variation( $item_id );
        $variation_data = $_product->get_variation_attributes();
        $variation_detail = woocommerce_get_formatted_variation( $variation_data, true );  // this will give all variation detail in one line
        // $variation_detail = woocommerce_get_formatted_variation( $variation_data, false);  // this will give all variation detail one by one
        return $variation_detail; // $variation_detail will return string containing variation detail which can be used to print on website
        // return $variation_data; // $variation_data will return only the data which can be used to store variation data
        $item_id = ( !empty( $cart_item['variation_id'] ) ) ? $cart_item['variation_id'] : '';
    		if ( !empty( $item_id ) ) {
       			$variations = get_variation_data_from_variation_id( $item_id );
    		}
    }

    Sry about the messy formatting!
    This gives me a string of Attributes for a given Variable product ID. I need a specific value, but that I will work out later. So far, I just need the value to be retuned from a Simple-CPO-Product. But I cannot figure out how the Attributes and Values are assigned to the cpo-product.

    I’m desperate here ?? I really hope there is a way to talk to your plugin, and pull those values from the cart.

    • This reply was modified 4 years ago by pandusen.
    Thread Starter pandusen

    (@pandusen)

    When duplicating a module, the slug of the module gained by duplicating must ALWAYS be reassigned. As I noticed, the system warns you with an exclamation mark and suggests a new slug name.

    You need to be clear about your problem. Do you have issues with duplicating Modules or Products?

    Dear Dev. could you perhaps make an update for the plugin, so that you issue a warning before people overwrite? It could be that you ask the user:
    “Warning: you are about to Overwrite a global option.”
    Give the user the option to Confirm overwrite, or to make new unique slug (based on either a +_1(in same module) or _”product-name”(If in a duplicate product))

    • This reply was modified 4 years, 3 months ago by pandusen.
    Thread Starter pandusen

    (@pandusen)

    next major version (which in fact will be Builderius, but you know it already if you follow our fb group)

    Story of my life. Just bought your plugin yesterday, the same day I became aware of you ?? no clue you had a facebook page.

    Thread Starter pandusen

    (@pandusen)

    The modules that you create for a product (lets call it Product-A) needs a slug name which needs to be unique.(Lets call it cpo_length) When you save the module for the first time, with DB checked, it creates a global attribute(option), which is called cpo_length, which resides in the database.(the list you se in cpo-options on the wp-dashboard) At the sametime it also linked with the module (Se sync ID in module), The module now has control over that attribute/option.

    When you duplicate a product(Product-B) with that module, it is now also linked to the same attribute/option: cpo_length_a, but as an instanced link. The copy process takes into account the origin of module option.

    cpo_length_a is now working on both products.

    If you open the module in Product-B and check the DB and press save, Product-B now recreates the link as if was the first time, reassigning a sync id, with no regard to product-A. product-A is no longer synced/attached/linked to cpo_length_a

    If you need to change a module in Product-B after copying, make sure to rename the slug: cpo_length_b before you save to the db. This way the module creates a new unique option: cpo_length_b and linkes that to the module in product-B, without touching the original cpo_length_a. Remember to change the calculation form in product-b module, to use the new option: cpo_lenth_b

    Hope that makes sense ??

    Thread Starter pandusen

    (@pandusen)

    You can just return to this thread i guess. i will look to it from time to time.

    Thread Starter pandusen

    (@pandusen)

    To fix a product which has stopped calculating. Go to the wp-dashboard > CPO-Options
    And delete all the Attributes/options related to the products modules.
    Go back to the product>CPO builder and go through the modules and save them(with DB turned on) one by one. This will recreate the Attribute/options in the database. Save the product and it should work.

    When duplicating a product, the link to the attributes are instanced(a symbolic link to the option) be careful not to save these modules with DB on, in any duplicated product as you will change it from instanced to direct link, and overwrite/takeover from the original product(This renders your original product useless)

    You can add new modules to the duplicated and save those to DB, as long as they have a unique name, as they will become new modules, linked directly to your duplicated product. I think if you need to change a module on the duplicated product which is instanced to the original product, you need to change the slug name to a unique name, before saving it with DB on. Remember, any visual changes or changes to labels etc(the ones without a yellow triangle) you do not need to tjek the save to DB option, and you can freely change these things without affecting the original products.

    It takes a little disciplene to wrap your head around, but once you get it, it seams to make sense. I am sure the dev is working on ways to warn/avoid this issue.

    Thread Starter pandusen

    (@pandusen)

    I think I got the hang of it now.. So far everything is behaving as expected, also on duplicated products.

    While I have your attention. Is there a way to disable the “Calculating” animation on the frontend? Seems a little redundant, to display a “loading” screen for a calculation that takes a nanosecond ?? (perhaps a feature request)

    Thread Starter pandusen

    (@pandusen)

    Yeah.. I am going to give it a go again.. Just went through the documentation on that part, Need to wrap my head around the instances and “direct” connection between the options.

    Thread Starter pandusen

    (@pandusen)

    I duplicated the product. Cause I need an identical product, with an additional feature.
    Guess duplicating products kills the options somehow.
    Will browse over the documentation, thought I read somewhere that it is supported.

    Thread Starter pandusen

    (@pandusen)

    Hi. Sry about the confusion of the “Calculation based on custom option” I was tied, and the gramma in the plugin isn’t exactly plus plus. The description for the feature seems that if you turn it off, it does not calculate the price.. Which I was also unsure of, hence the title was suggesting the opposite. Just decided to mention it, so you could clarify it.

    I found the problem to be a screwup in the options / db. I tried to resync the options, but the sync function only lets me hit auto fetch, and was selecting random stuff, no way for me to point to the correct option.(either or I just dont get the sync feature)

    I solved it by going to CPO Options and delete all the attributes, and then go through the modules one by one in the builder, resaving them to db.

    Original theme switched back on, as well as all the plugins. It seems to be working.

    Thread Starter pandusen

    (@pandusen)

    Thank you for the quick response. I have deactivated all plugins, except Woo and CPO
    And switched to storefront. It made a slight difference, in the way that it now calculated the default value(initial state) of the forms, which is like 625,-. And when added to the cart, that number gets added. but if I change the the values, and the number becomes like 1250,- and add that to the cart, it gets added as 625,-.
    So it seems to be stock.

    Also, calculation on the single product page, only works with the “Enable price calculation based on custom options” enabled. Id i turn it off, the product just stays on 1,- which is the base price of the “simple product” And no amount of adjustment will change that. All values and calculations are disregarded, if I disable the “Enable price calculation based on custom options”.

    Would you like an admin-user to the site, so you can have a look?

    • This reply was modified 4 years, 3 months ago by pandusen.
    • This reply was modified 4 years, 3 months ago by pandusen.
Viewing 11 replies - 1 through 11 (of 11 total)