• bambii09

    (@bambii09)


    I need help with creating a snippet for Woocommerce memberships. I see you created the one below and one for the subscriptions. But neither is working for me. Can you assist?

    thanks!

    class WOE_Memberships {
    var $fields = array(“plan”,”status”,”since”,”expires”);
    function __construct() {

    add_filter(‘woe_get_order_fields’, function ($fields) {
    foreach($this->fields as $f) {
    $fields[‘membership_’.$f] = array( ‘label’ => “Member $f”, ‘colname’ => “Member $f”, ‘checked’ => 1 );

    add_filter(‘woe_get_order_value_membership_’.$f, function ($value,$order,$field) {
    return isset($this->data[$field]) ? $this->data[$field] : $value;
    },10,3);
    }
    return $fields;
    });

    // rebuild for each order
    add_filter(‘woe_order_export_started’, function ($order_id) {
    // each order can create many memberships!
    $this->data = array();
    foreach($this->fields as $f)
    $this->data[$f] = array();

    //gather details
    $memberships = wc_memberships()->get_user_memberships_instance()->get_user_membership_by_order_id($order_id);
    foreach ($memberships as $m) {
    $this->data[‘plan’][] = $m->get_plan()->get_name();
    $this->data[‘status’][] = $m->get_status();
    $this->data[‘since’][] = $m->get_start_date();
    $this->data[‘expires’][] = $m->get_end_date();
    }

    // convert to multiline cells
    foreach($this->data as $f=>$v)
    $this->data[‘membership_’.$f] = join(“\n”, $v );
    return $order_id;
    });
    }
    }
    new WOE_Memberships();

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author algol.plus

    (@algolplus)

    hi

    How did you add custom code ? via plugin “code snippets” ? functions.php ?

    Do you see new columns “Member plan”( and others) in Preview ?

    thanks, Alex

    Thread Starter bambii09

    (@bambii09)

    Hello, Yes I added via code snippets.

    I do see member plan, and it will export it as a column but nothing is showing in the column.

    Plugin Author algol.plus

    (@algolplus)

    hello

    probably, this code is outdated.

    Could you submit ticket to helpdesk and upload fresh version of Membership plugin?

    thanks, Alex

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Do you have support for Woocommerce Memberships’’ is closed to new replies.