Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter applecrabs

    (@applecrabs)

    Just an update to this – it’s a different library but the same problem:

    https://github.com/geoffjentry/twitteR/issues/80

    It appears that 140 chars minus the chars for the https://t.co/ url is 116, so that’s probably where it’s falling down.

    Thread Starter applecrabs

    (@applecrabs)

    I’ve taken another look at this – I can change it to

    class WC_Product_Customshirt extends WC_Product_Variable

    but the only way I can keep it as the product_type ‘customshirt’ is to force it by doing this:

            public function __construct( $product ) {
               $this->product_type = 'customshirt';
               parent::__construct( $product );
            }
    
            public function get_type() {
                return 'customshirt'; //without this it reverts back to 'variable' product type in the drop down
            }

    Otherwise it reverts back to a normal variable product.

    EDIT: if it stays as customshirt there are still no variations available

    I’ve uploaded the plugin code I’ve got at the moment to Pastebin in case anybody can see where this is falling down (except it being a total mess a bit further in) – https://pastebin.com/i6qecQ80

    As I mentioned before, I’ve duplicated the whole WC_Product_Variable class and renamed it in the hope of just being able to extend WC_Product, but that’s not having a tremendous amount of joy either. As always – any help or suggestions welcome, am starting to go slightly mad now.

    • This reply was modified 8 years, 3 months ago by applecrabs.
    Thread Starter applecrabs

    (@applecrabs)

    Hi Caleb,

    Thanks for your response – I’ve tried extending WC_Product_Variable – that does at first appear to work, but turns out it just sets the product type back to ‘variable’, which isn’t much good to me. I need it to be a new product type in order for it to work properly unless I really hack around it.

    The reason I’ve duplicated the WC_Product_Variable class in its entirety (and it isn’t really what I was setting out to do) is because it seems to be where get_available_variations is set – but by duplicating (and renaming) it, I don’t have the problem of it reverting the product_type back to ‘variable’.

    The current way seems to keep the product type I need to use and allows me to add more conditional custom meta options. I could potentially just use the ‘variable’ product type and add a checkbox, but would much rather not unless I have to.

    That said, I will take another look tomorrow morning when I’m back in the office, unless anybody else knows of a way around this, or can give a pointer.

    Thanks again.

    Thread Starter applecrabs

    (@applecrabs)

    Just to add to this – if I change the product type to ‘variable’ it works fine on the font-end.

Viewing 4 replies - 1 through 4 (of 4 total)